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

Representation of a compile-time instance of a port. More...

Inherits org.lflang.generator.TriggerInstance< Port >.

Public Member Functions

void clearCaches ()
 Clear cached information about the connectivity of this port.
List< Connection > connectionsFrom (PortInstance upstreamPort)
 For the given upstream port (the instance of a range returned by getDependsOnPorts()), return a list of connections from that port or null if there are no connections from that port.
List< Connection > connectionsTo (PortInstance downstreamPort)
 For the given downstream port (the instance of a range returned by getDependentPorts()), return a list of connections to that port or null if there are no connections to that port.
List< SendRangeeventualDestinations ()
 Return a list of ranges of this port, where each range sends to a list of destination ports that receive data from the range of this port.
List< RuntimeRange< PortInstance > > eventualSources ()
 Return a list of ranges of ports that send data to this port.
List< SendRangegetDependentPorts ()
 Return the list of ranges of this port together with the downstream ports that are connected to this port.
Set< ReactionInstancegetDependentReactions ()
 Return the reaction instances that are triggered or read by this trigger.
List< RuntimeRange< PortInstance > > getDependsOnPorts ()
 Return the list of upstream ports that are connected to this port, or an empty set if there are none.
Set< ReactionInstancegetDependsOnReactions ()
 Return the reaction instances that may send data via this port or action.
int getLevelUpperBound (MixedRadixInt index)
 Return the minimum of the levels of the reactions that are downstream of this port.
String getName ()
 Return the name of this trigger.
boolean isInput ()
 Return true if the port is an input.
boolean isMultiport ()
 Return true if this is a multiport.
boolean isOutput ()
 Return true if the port is an output.
boolean isReset ()
 Return true if this trigger is "startup".
boolean isShutdown ()
 Return true if this trigger is "shutdown".
boolean isStartup ()
 Return true if this trigger is "startup".
TimeValue minDelayFrom (PortInstance upstreamPort)
 For the given upstream port (the instance of a range returned by getDependsOnPorts()), return the minimum of the after delays on connections from that port.
 PortInstance (Port definition, ReactorInstance parent)
 Create a runtime instance from the specified definition and with the specified parent that instantiated it.
 PortInstance (Port definition, ReactorInstance parent, MessageReporter messageReporter)
 Create a port instance from the specified definition and with the specified parent that instantiated it.
void recordIndexForPortChannel (MixedRadixInt index, int level)
 Record that the indexth sub-port of this has a dependent reaction of level level.
String toString ()

Static Package Functions

static TriggerInstance< BuiltinTriggerVariable > builtinTrigger (BuiltinTriggerRef trigger, ReactorInstance parent)
 Construct a new instance for a special builtin trigger.

Package Attributes

List< SendRangedependentPorts = new ArrayList<>()
 Ranges of this port together with downstream ports that are connected directly to this port.
Set< ReactionInstancedependentReactions
 Reaction instances that are triggered or read by this trigger.
List< RuntimeRange< PortInstance > > dependsOnPorts = new ArrayList<>(1)
 Upstream ports that are connected directly to this port, if there are any.
Set< ReactionInstancedependsOnReactions
 Reaction instances that may send data via this port or action.
Map< PortInstance, List< Connection > > downstreamConnections = new LinkedHashMap<>(1)
 Map from the ports listed in dependentPorts to the connection(s) to those ports.
boolean isMultiport = false
 Indicator of whether this is a multiport.
Map< PortInstance, List< Connection > > upstreamConnections = new LinkedHashMap<>(1)
 Map from the ports listed in dependsOnPorts to the connection(s) from those ports.

Detailed Description

Representation of a compile-time instance of a port.

Like ReactorInstance, if one or more parents of this port is a bank of reactors, then there will be more than one runtime instance corresponding to this compile-time instance.

This may be a single port or a multiport. If it is a multiport, then one instance of this PortInstance class represents all channels. If in addition any parent is a bank, then it represents all channels of all bank members. The eventualDestinations() and eventualSources() functions report the connectivity of all such channels as lists of SendRange and RuntimeRange objects.

Author
Marten Lohstroh
Edward A. Lee

Constructor & Destructor Documentation

◆ PortInstance() [1/2]

org.lflang.generator.PortInstance.PortInstance ( Port definition,
ReactorInstance parent )

Create a runtime instance from the specified definition and with the specified parent that instantiated it.

Parameters
definitionThe declaration in the AST.
parentThe parent.

◆ PortInstance() [2/2]

org.lflang.generator.PortInstance.PortInstance ( Port definition,
ReactorInstance parent,
MessageReporter messageReporter )

Create a port instance from the specified definition and with the specified parent that instantiated it.

Parameters
definitionThe declaration in the AST.
parentThe parent.
messageReporterAn error reporter, or null to throw exceptions.

Member Function Documentation

◆ builtinTrigger()

TriggerInstance< BuiltinTriggerVariable > org.lflang.generator.TriggerInstance< T extends Variable >.builtinTrigger ( BuiltinTriggerRef trigger,
ReactorInstance parent )
staticpackageinherited

Construct a new instance for a special builtin trigger.

Parameters
triggerThe actual trigger definition.
parentThe reactor instance that creates this instance.

◆ clearCaches()

void org.lflang.generator.PortInstance.clearCaches ( )

Clear cached information about the connectivity of this port.

In particular, eventualDestinations() and eventualSources() cache the lists they return. To force those methods to recompute their lists, call this method. This method also clears the caches of any ports that are listed as eventual destinations and sources.

◆ connectionsFrom()

List< Connection > org.lflang.generator.PortInstance.connectionsFrom ( PortInstance upstreamPort)

For the given upstream port (the instance of a range returned by getDependsOnPorts()), return a list of connections from that port or null if there are no connections from that port.

Parameters
upstreamPortThe upstream port.

◆ connectionsTo()

List< Connection > org.lflang.generator.PortInstance.connectionsTo ( PortInstance downstreamPort)

For the given downstream port (the instance of a range returned by getDependentPorts()), return a list of connections to that port or null if there are no connections to that port.

Parameters
downstreamPortThe downstream port.

◆ eventualDestinations()

List< SendRange > org.lflang.generator.PortInstance.eventualDestinations ( )

Return a list of ranges of this port, where each range sends to a list of destination ports that receive data from the range of this port.

Each destination port is annotated with the channel range on which it receives data. The ports listed are only ports that are sources for reactions, not relay ports that the data may go through on the way. Also, if there is an "after" delay anywhere along the path, then the destination is not in the resulting list.

If this port itself has dependent reactions, then this port will be included as a destination in all items on the returned list.

Each item in the returned list has the following fields:

  • startRange: The starting channel index of this port.
  • rangeWidth: The number of channels sent to the destinations.
  • destinations: A list of port ranges for destination ports, each of which has the same width as rangeWidth.

Each item also has a method, SendRange#getNumberOfDestinationReactors(), that returns the total number of unique destination reactors for its range. This is not necessarily the same as the number of ports in its destinations field because some of the ports may share the same container reactor.

◆ eventualSources()

List< RuntimeRange< PortInstance > > org.lflang.generator.PortInstance.eventualSources ( )

Return a list of ranges of ports that send data to this port.

If this port is directly written to by one or more reactions, then it is its own eventual source and only this port will be represented in the result.

If this is not a multiport and is not within a bank, then the list will have only one item and the range will have a total width of one. Otherwise, it will have enough items so that the range widths add up to the width of this multiport multiplied by the total number of instances within containing banks.

The ports listed are only ports that are written to by reactions, not relay ports that the data may go through on the way.

◆ getDependentPorts()

List< SendRange > org.lflang.generator.PortInstance.getDependentPorts ( )

Return the list of ranges of this port together with the downstream ports that are connected to this port.

The total with of the ranges in the returned list is a multiple N >= 0 of the total width of this port.

◆ getDependentReactions()

Set< ReactionInstance > org.lflang.generator.TriggerInstance< T extends Variable >.getDependentReactions ( )
inherited

Return the reaction instances that are triggered or read by this trigger.

If this port is an output, then the reaction instances belong to the parent of the port's parent. If the port is an input, then the reaction instances belong to the port's parent.

◆ getDependsOnPorts()

List< RuntimeRange< PortInstance > > org.lflang.generator.PortInstance.getDependsOnPorts ( )

Return the list of upstream ports that are connected to this port, or an empty set if there are none.

For an ordinary port, this list will have length 0 or 1. For a multiport, it can have a larger size.

◆ getDependsOnReactions()

Set< ReactionInstance > org.lflang.generator.TriggerInstance< T extends Variable >.getDependsOnReactions ( )
inherited

Return the reaction instances that may send data via this port or action.

If this is an input port, then the reaction instance belongs to parent of the port's parent. If it is an output port, the reaction instance belongs to the port's parent. If it is an action, then the reaction belongs to the same parent as that of this action.

◆ getLevelUpperBound()

int org.lflang.generator.PortInstance.getLevelUpperBound ( MixedRadixInt index)

Return the minimum of the levels of the reactions that are downstream of this port.

If there are no reactions downstream of this port, this returns Integer.MAX_VALUE.

◆ getName()

String org.lflang.generator.TriggerInstance< T extends Variable >.getName ( )
inherited

Return the name of this trigger.

Returns
The name of this trigger.

◆ isInput()

boolean org.lflang.generator.PortInstance.isInput ( )

Return true if the port is an input.

◆ isMultiport()

boolean org.lflang.generator.PortInstance.isMultiport ( )

Return true if this is a multiport.

◆ isOutput()

boolean org.lflang.generator.PortInstance.isOutput ( )

Return true if the port is an output.

◆ isReset()

boolean org.lflang.generator.TriggerInstance< T extends Variable >.isReset ( )
inherited

Return true if this trigger is "startup".

/

◆ isShutdown()

boolean org.lflang.generator.TriggerInstance< T extends Variable >.isShutdown ( )
inherited

Return true if this trigger is "shutdown".

◆ isStartup()

boolean org.lflang.generator.TriggerInstance< T extends Variable >.isStartup ( )
inherited

Return true if this trigger is "startup".

/

◆ minDelayFrom()

TimeValue org.lflang.generator.PortInstance.minDelayFrom ( PortInstance upstreamPort)

For the given upstream port (the instance of a range returned by getDependsOnPorts()), return the minimum of the after delays on connections from that port.

This will be TimeValue.ZERO if there are no after delays or if the after delays are zero, and it will be TimeValue.MAX_VALUE if there are no connections from the port.

Parameters
upstreamPortThe upstream port.

◆ recordIndexForPortChannel()

void org.lflang.generator.PortInstance.recordIndexForPortChannel ( MixedRadixInt index,
int level )

Record that the indexth sub-port of this has a dependent reaction of level level.

◆ toString()

String org.lflang.generator.PortInstance.toString ( )

Member Data Documentation

◆ dependentPorts

List<SendRange> org.lflang.generator.PortInstance.dependentPorts = new ArrayList<>()
package

Ranges of this port together with downstream ports that are connected directly to this port.

When there are multiple destinations, the destinations are listed in the order they appear in connections in the parent reactor instance of this port (inside connections), followed by the order in which they appear in the parent's parent (outside connections). The total of the widths of these SendRanges is an integer multiple N >= 0 of the width of this port (this is checked by the validator). Each channel of this port will be broadcast to N recipients (or, if there are no connections to zero recipients).

◆ dependentReactions

Set<ReactionInstance> org.lflang.generator.TriggerInstance< T extends Variable >.dependentReactions
packageinherited

Reaction instances that are triggered or read by this trigger.

If this port is an output, then the reaction instances belong to the parent of the port's parent. If the port is an input, then the reaction instances belong to the port's parent.

◆ dependsOnPorts

List<RuntimeRange<PortInstance> > org.lflang.generator.PortInstance.dependsOnPorts = new ArrayList<>(1)
package

Upstream ports that are connected directly to this port, if there are any.

For an ordinary port, this set will have size 0 or 1. For a multiport, it can have a larger size. This initially has capacity 1 because that is by far the most common case.

◆ dependsOnReactions

Set<ReactionInstance> org.lflang.generator.TriggerInstance< T extends Variable >.dependsOnReactions
packageinherited

Reaction instances that may send data via this port or action.

If this is an input port, then the reaction instance belongs to parent of the port's parent. If it is an output port, the reaction instance belongs to the port's parent. If it is an action, then the reaction belongs belongs to the same parent as this action.

◆ downstreamConnections

Map<PortInstance, List<Connection> > org.lflang.generator.PortInstance.downstreamConnections = new LinkedHashMap<>(1)
package

Map from the ports listed in dependentPorts to the connection(s) to those ports.

◆ isMultiport

boolean org.lflang.generator.PortInstance.isMultiport = false
package

Indicator of whether this is a multiport.

◆ upstreamConnections

Map<PortInstance, List<Connection> > org.lflang.generator.PortInstance.upstreamConnections = new LinkedHashMap<>(1)
package

Map from the ports listed in dependsOnPorts to the connection(s) from those ports.


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