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

Class that represents an instance of a federate, i.e., a reactor that is instantiated at the top level of a federated reactor. More...

Public Member Functions

 FederateInstance (Instantiation instantiation, int id, int bankIndex, int bankWidth, TargetConfig targetConfig, MessageReporter messageReporter)
 Construct a new federate instance on the basis of an instantiation in the federated reactor.
LinkedHashMap< Output, TimeValuefindOutputsConnectedToPhysicalActions (ReactorInstance instance)
 Find output ports that are connected to a physical action trigger upstream in the same reactor.
ActionInstance findPhysicalAction (ReactorInstance instance)
 Return the first found physical action or null if there is no physical action in this federate.
Instantiation getInstantiation ()
boolean includes (Action action)
 Return true if this federate includes a top-level reaction that references the given action as a trigger, a source, or an effect.
boolean includes (Reaction reaction)
 Return true if the specified reaction should be included in the code generated for this federate at the top-level.
boolean includes (ReactorInstance instance)
 Return true if this federate instance includes the given instance.
boolean includes (Timer timer)
 Return true if this federate includes a top-level reaction that references the given timer as a trigger, a source, or an effect.
boolean isInZeroDelayCycle ()
 Return true if there is a zero-delay path from this federate to itself.
boolean references (Import imp)
 Return true if this federate references the given import.
boolean references (Parameter param)
 Return true if this federate references the given parameter.
boolean references (ReactorDecl declaration)
 Return true if the class declaration of the given instantiation references the declaration of a reactor class, either directly or indirectly (i.e, via a superclass or a contained instantiation of the reactor class).
String toString ()

Public Attributes

int bankIndex
 The position within a bank of reactors for this federate.
int bankWidth
 The width of the bank in which this federate was instantiated.
Set< FedConnectionInstanceconnections = new LinkedHashSet<>()
 A list of individual connections between federates.
Map< FederateInstance, Set< Expression > > dependsOn = new LinkedHashMap<>()
 Map from the federates that this federate receives messages from to the delays on connections from that federate.
HashSet< SupportedSerializersenabledSerializers = new HashSet<>()
 Keep a unique list of enabled serializers.
String host = "localhost"
 The host, if specified using the 'at' keyword.
int id
 The integer ID of this federate.
Set< FederateInstanceinboundP2PConnections = new LinkedHashSet<>()
 A set of federates with which this federate has an inbound connection There will only be one physical connection even if federate A has defined multiple physical connections to federate B.
Instantiation instantiation
 The instantiation of the top-level reactor, or null if there is no federation.
boolean isRemote = false
 Indicates whether the federate is remote or local.
String name
 The name of this federate instance.
HashMap< Action, Instantiation > networkActionToInstantiation = new HashMap<>()
 Keep a map of network actions to their associated instantiations.
List< Connection > networkConnections = new ArrayList<>()
 List of generated network connections (network input and outputs) that belong to this federate instance.
List< Instantiation > networkHelperInstantiations = new ArrayList<>()
 List of generated instantiations that serve as helpers for forming the network connections.
int networkIdSender = 0
 The counter used to assign IDs to network senders.
List< Expression > networkMessageActionDelays = new ArrayList<>()
 List of after delay values of the corresponding entries of networkMessageActions.
List< Action > networkMessageActions = new ArrayList<>()
 List of networkMessage actions.
List< FederateInstancenetworkMessageSourceFederate = new ArrayList<>()
 List of source federate IDs for networkMessage actions.
Map< PortInstance, Instantiation > networkPortToIndexer = new HashMap<>()
 The mapping from network multiports of the federate to indexer reactors that split the multiport into individual ports.
Map< PortInstance, Instantiation > networkPortToInstantiation = new HashMap<>()
 Mapping from a port instance of a connection to its associated network reaction.
List< Reactor > networkReactors = new ArrayList<>()
 List of generated network reactors (network input and outputs) that belong to this federate instance.
List< Instantiation > networkReceiverInstantiations = new ArrayList<>()
 List of generated network instantiations (network input and outputs) that belong to this federate instance.
List< Reaction > networkReceiverReactions = new ArrayList<>()
 List of generated network reactions (network receivers) that belong to this federate instance.
List< Instantiation > networkSenderInstantiations = new ArrayList<>()
 List of generated network instantiations (network input and outputs) that belong to this federate instance.
List< Reaction > networkSenderReactions = new ArrayList<>()
 List of generated network reactions (network sender) that belong to this federate instance.
Set< FederateInstanceoutboundP2PConnections = new LinkedHashSet<>()
 A list of federate with which this federate has an outbound physical connection.
int port = 0
 The port, if specified using the 'at' keyword.
List< Reaction > portAbsentReactions = new ArrayList<>()
 List of generated network control reactions (network sender) that belong to this federate instance.
Map< FederateInstance, Set< Expression > > sendsTo = new LinkedHashMap<>()
 Map from the federates that this federate sends messages to the delays on connections to that federate.
SortedSet< TimeValuestaaOffsets = new TreeSet<TimeValue>()
 A list of unique STAA offsets over all input ports of this federate.
HashMap< TimeValue, List< Action > > staToNetworkActionMap = new HashMap<>()
 Keep a map of STP values to a list of network actions.
TargetConfig targetConfig
 Parsed target config of the federate.
String user = null
 The user, if specified using the 'at' keyword.
List< Action > zeroDelayCycleNetworkMessageActions = new ArrayList<>()
 List of networkMessage actions corresponding to network input ports whose upstream federates are in zero-delay cycles and the connection has no after delay.

Package Functions

private< T > List< T > convertToEmptyListIfNull (List< T > list)

Detailed Description

Class that represents an instance of a federate, i.e., a reactor that is instantiated at the top level of a federated reactor.

Author
Edward A. Lee
Soroush Bateni

Constructor & Destructor Documentation

◆ FederateInstance()

org.lflang.federated.generator.FederateInstance.FederateInstance ( Instantiation instantiation,
int id,
int bankIndex,
int bankWidth,
TargetConfig targetConfig,
MessageReporter messageReporter )

Construct a new federate instance on the basis of an instantiation in the federated reactor.

Parameters
instantiationThe AST node of the instantiation.
idAn identifier.
bankIndexIf instantiation.widthSpec !== null, this gives the bank position.
bankWidthThe width of the bank.
targetConfigThe target configuration.
messageReporterAn object for reporting messages to the user.

Member Function Documentation

◆ convertToEmptyListIfNull()

private< T > List< T > org.lflang.federated.generator.FederateInstance.convertToEmptyListIfNull ( List< T > list)
package

◆ findOutputsConnectedToPhysicalActions()

LinkedHashMap< Output, TimeValue > org.lflang.federated.generator.FederateInstance.findOutputsConnectedToPhysicalActions ( ReactorInstance instance)

Find output ports that are connected to a physical action trigger upstream in the same reactor.

Return a list of such outputs paired with the minimum delay from the nearest physical action.

Parameters
instanceThe reactor instance containing the output ports
Returns
A LinkedHashMap<Output, TimeValue>

◆ findPhysicalAction()

ActionInstance org.lflang.federated.generator.FederateInstance.findPhysicalAction ( ReactorInstance instance)

Return the first found physical action or null if there is no physical action in this federate.

Parameters
instanceThe reactor instance to check whether there is a physical action.

◆ getInstantiation()

Instantiation org.lflang.federated.generator.FederateInstance.getInstantiation ( )

◆ includes() [1/4]

boolean org.lflang.federated.generator.FederateInstance.includes ( Action action)

Return true if this federate includes a top-level reaction that references the given action as a trigger, a source, or an effect.

Parameters
actionThe action to check whether it is to be included.

◆ includes() [2/4]

boolean org.lflang.federated.generator.FederateInstance.includes ( Reaction reaction)

Return true if the specified reaction should be included in the code generated for this federate at the top-level.

This means that if the reaction is triggered by or sends data to a port of a contained reactor, then that reaction is in the federate. Otherwise, return false.

NOTE: This method assumes that it will not be called with reaction arguments that are within other federates. It should only be called on reactions that are either at the top level or within this federate. For this reason, for any reaction not at the top level, it returns true.

Parameters
reactionThe reaction to check whether it is to be included.

◆ includes() [3/4]

boolean org.lflang.federated.generator.FederateInstance.includes ( ReactorInstance instance)

Return true if this federate instance includes the given instance.

NOTE: If the instance is a bank within the top level, then this returns true even though only one of the bank members is included in the federate.

Parameters
instanceThe reactor instance to check whether it is to be included.

◆ includes() [4/4]

boolean org.lflang.federated.generator.FederateInstance.includes ( Timer timer)

Return true if this federate includes a top-level reaction that references the given timer as a trigger, a source, or an effect.

Parameters
timerThe action to check whether it is to be included.

◆ isInZeroDelayCycle()

boolean org.lflang.federated.generator.FederateInstance.isInZeroDelayCycle ( )

Return true if there is a zero-delay path from this federate to itself.

This is used to determine whether absent messages need to be sent. Note that this is not the same as causality loop detection. A federate may be in a zero-delay cycle (ZDC) even if there is no causality loop.

◆ references() [1/3]

boolean org.lflang.federated.generator.FederateInstance.references ( Import imp)

Return true if this federate references the given import.

Parameters
impThe import to check whether it is referenced.

◆ references() [2/3]

boolean org.lflang.federated.generator.FederateInstance.references ( Parameter param)

Return true if this federate references the given parameter.

Parameters
paramThe parameter to check whether it is referenced.

◆ references() [3/3]

boolean org.lflang.federated.generator.FederateInstance.references ( ReactorDecl declaration)

Return true if the class declaration of the given instantiation references the declaration of a reactor class, either directly or indirectly (i.e, via a superclass or a contained instantiation of the reactor class).

Parameters
declarationThe reactor declaration to check whether it is referenced.

◆ toString()

String org.lflang.federated.generator.FederateInstance.toString ( )

Member Data Documentation

◆ bankIndex

int org.lflang.federated.generator.FederateInstance.bankIndex

The position within a bank of reactors for this federate.

This is 0 if the instantiation is not a bank of reactors.

◆ bankWidth

int org.lflang.federated.generator.FederateInstance.bankWidth

The width of the bank in which this federate was instantiated.

This is 1 if the instantiation is not a bank of reactors.

◆ connections

Set<FedConnectionInstance> org.lflang.federated.generator.FederateInstance.connections = new LinkedHashSet<>()

A list of individual connections between federates.

◆ dependsOn

Map<FederateInstance, Set<Expression> > org.lflang.federated.generator.FederateInstance.dependsOn = new LinkedHashMap<>()

Map from the federates that this federate receives messages from to the delays on connections from that federate.

The delay set may include null, meaning that there is a connection from the federate instance that has no delay.

◆ enabledSerializers

HashSet<SupportedSerializers> org.lflang.federated.generator.FederateInstance.enabledSerializers = new HashSet<>()

Keep a unique list of enabled serializers.

◆ host

String org.lflang.federated.generator.FederateInstance.host = "localhost"

The host, if specified using the 'at' keyword.

◆ id

int org.lflang.federated.generator.FederateInstance.id

The integer ID of this federate.

◆ inboundP2PConnections

Set<FederateInstance> org.lflang.federated.generator.FederateInstance.inboundP2PConnections = new LinkedHashSet<>()

A set of federates with which this federate has an inbound connection There will only be one physical connection even if federate A has defined multiple physical connections to federate B.

The message handler on federate A will be responsible for including the appropriate information in the message header (such as port ID) to help the receiver distinguish different events.

◆ instantiation

Instantiation org.lflang.federated.generator.FederateInstance.instantiation

The instantiation of the top-level reactor, or null if there is no federation.

◆ isRemote

boolean org.lflang.federated.generator.FederateInstance.isRemote = false

Indicates whether the federate is remote or local.

◆ name

String org.lflang.federated.generator.FederateInstance.name

The name of this federate instance.

This will be the instantiation name, possibly appended with "__n", where n is the bank position of this instance if the instantiation is of a bank of reactors.

◆ networkActionToInstantiation

HashMap<Action, Instantiation> org.lflang.federated.generator.FederateInstance.networkActionToInstantiation = new HashMap<>()

Keep a map of network actions to their associated instantiations.

◆ networkConnections

List<Connection> org.lflang.federated.generator.FederateInstance.networkConnections = new ArrayList<>()

List of generated network connections (network input and outputs) that belong to this federate instance.

◆ networkHelperInstantiations

List<Instantiation> org.lflang.federated.generator.FederateInstance.networkHelperInstantiations = new ArrayList<>()

List of generated instantiations that serve as helpers for forming the network connections.

◆ networkIdSender

int org.lflang.federated.generator.FederateInstance.networkIdSender = 0

The counter used to assign IDs to network senders.

◆ networkMessageActionDelays

List<Expression> org.lflang.federated.generator.FederateInstance.networkMessageActionDelays = new ArrayList<>()

List of after delay values of the corresponding entries of networkMessageActions.

These will be null in the case of zero-delay connections and 0 in the case of microstep-delay connections.

◆ networkMessageActions

List<Action> org.lflang.federated.generator.FederateInstance.networkMessageActions = new ArrayList<>()

List of networkMessage actions.

Each of these handles a message received from another federate over the network. The ID of receiving port is simply the position of the action in the list. The sending federate needs to specify this ID.

◆ networkMessageSourceFederate

List<FederateInstance> org.lflang.federated.generator.FederateInstance.networkMessageSourceFederate = new ArrayList<>()

List of source federate IDs for networkMessage actions.

◆ networkPortToIndexer

Map<PortInstance, Instantiation> org.lflang.federated.generator.FederateInstance.networkPortToIndexer = new HashMap<>()

The mapping from network multiports of the federate to indexer reactors that split the multiport into individual ports.

◆ networkPortToInstantiation

Map<PortInstance, Instantiation> org.lflang.federated.generator.FederateInstance.networkPortToInstantiation = new HashMap<>()

Mapping from a port instance of a connection to its associated network reaction.

We populate this map as we process connections as a means of annotating intra-federate dependencies

◆ networkReactors

List<Reactor> org.lflang.federated.generator.FederateInstance.networkReactors = new ArrayList<>()

List of generated network reactors (network input and outputs) that belong to this federate instance.

◆ networkReceiverInstantiations

List<Instantiation> org.lflang.federated.generator.FederateInstance.networkReceiverInstantiations = new ArrayList<>()

List of generated network instantiations (network input and outputs) that belong to this federate instance.

◆ networkReceiverReactions

List<Reaction> org.lflang.federated.generator.FederateInstance.networkReceiverReactions = new ArrayList<>()

List of generated network reactions (network receivers) that belong to this federate instance.

◆ networkSenderInstantiations

List<Instantiation> org.lflang.federated.generator.FederateInstance.networkSenderInstantiations = new ArrayList<>()

List of generated network instantiations (network input and outputs) that belong to this federate instance.

◆ networkSenderReactions

List<Reaction> org.lflang.federated.generator.FederateInstance.networkSenderReactions = new ArrayList<>()

List of generated network reactions (network sender) that belong to this federate instance.

◆ outboundP2PConnections

Set<FederateInstance> org.lflang.federated.generator.FederateInstance.outboundP2PConnections = new LinkedHashSet<>()

A list of federate with which this federate has an outbound physical connection.

There will only be one physical connection even if federate A has defined multiple physical connections to federate B. The message handler on federate B will be responsible for distinguishing the incoming messages by parsing their header and scheduling the appropriate action.

◆ port

int org.lflang.federated.generator.FederateInstance.port = 0

The port, if specified using the 'at' keyword.

◆ portAbsentReactions

List<Reaction> org.lflang.federated.generator.FederateInstance.portAbsentReactions = new ArrayList<>()

List of generated network control reactions (network sender) that belong to this federate instance.

◆ sendsTo

Map<FederateInstance, Set<Expression> > org.lflang.federated.generator.FederateInstance.sendsTo = new LinkedHashMap<>()

Map from the federates that this federate sends messages to the delays on connections to that federate.

The delay set may include null, meaning that there is a connection from the federate instance that has no delay.

◆ staaOffsets

SortedSet<TimeValue> org.lflang.federated.generator.FederateInstance.staaOffsets = new TreeSet<TimeValue>()

A list of unique STAA offsets over all input ports of this federate.

◆ staToNetworkActionMap

HashMap<TimeValue, List<Action> > org.lflang.federated.generator.FederateInstance.staToNetworkActionMap = new HashMap<>()

Keep a map of STP values to a list of network actions.

◆ targetConfig

TargetConfig org.lflang.federated.generator.FederateInstance.targetConfig

Parsed target config of the federate.

◆ user

String org.lflang.federated.generator.FederateInstance.user = null

The user, if specified using the 'at' keyword.

◆ zeroDelayCycleNetworkMessageActions

List<Action> org.lflang.federated.generator.FederateInstance.zeroDelayCycleNetworkMessageActions = new ArrayList<>()

List of networkMessage actions corresponding to network input ports whose upstream federates are in zero-delay cycles and the connection has no after delay.

This should be a subset of the networkMessageActions.


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/FederateInstance.java