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

Utility class for the C extension. More...

Static Public Member Functions

static void addClockSyncCompileDefinitions (FederateInstance federate)
 Initialize clock synchronization (if enabled) and its related options for a given federate.
static void addDisableClockSyncCompileDefinitions (FederateInstance federate)
static String createPortStatusFieldForInput (Input input)
 Create a port status field variable for a network input port "input" in the self struct of a reactor.
static void generateCMakeInclude (FederateInstance federate, FederationFileConfig fileConfig) throws IOException
 Generate a file to be included by CMake.
static String generateFederateNeighborStructure (FederateInstance federate)
 Generate code that sends the neighbor structure message to the RTI.
static String generateSerializationCMakeExtension (FederateInstance federate)
 Generate cmake-include code needed for enabled serializers of the federate.
static String generateSerializationIncludes (FederateInstance federate)
 Generate preamble code needed for enabled serializers of the federate.
static String getNetworkDelayLiteral (Expression delay)
 Given a connection 'delay' expression, return a string that represents the interval_t value of the additional delay that needs to be applied to the outgoing message.
static void handleCompileDefinitions (FederateInstance federate, List< String > federateNames, RtiConfig rtiConfig, MessageReporter messageReporter)
static void initializeClockSynchronization (FederateInstance federate, RtiConfig rtiConfig, MessageReporter messageReporter)
 Initialize clock synchronization (if enabled) and its related options for a given federate.
static String initializeTriggersForNetworkActions (FederateInstance federate, ReactorInstance main)
 Generate C code that initializes network actions.
static String stpStructs (FederateInstance federate)
 Generate C code that holds a sorted list of STAA structs by time.
static String surroundWithIfElseFederated (String insideIf, String insideElse)
static String surroundWithIfElseFederatedCentralized (String insideIf, String insideElse)
static String surroundWithIfFederated (String code)
 Surround code with blocks to ensure that code only executes if the program is federated.
static String surroundWithIfFederatedCentralized (String code)
 Surround code with blocks to ensure that code only executes if the program is federated and has a centralized coordination.
static String surroundWithIfFederatedDecentralized (String code)
 Surround code with blocks to ensure that code only executes if the program is federated and has a decentralized coordination.

Static Package Functions

static boolean clockSyncIsOn (FederateInstance federate, RtiConfig rtiConfig)
static boolean isSharedPtrType (InferredType type, CTypes types)

Static Package Attributes

static final Pattern sharedPointerVariable

Detailed Description

Utility class for the C extension.

Author
Soroush Bateni

Member Function Documentation

◆ addClockSyncCompileDefinitions()

void org.lflang.federated.extensions.CExtensionUtils.addClockSyncCompileDefinitions ( FederateInstance federate)
static

Initialize clock synchronization (if enabled) and its related options for a given federate.

Clock synchronization can be enabled using the clock-sync target property.

See also
Documentation

◆ addDisableClockSyncCompileDefinitions()

void org.lflang.federated.extensions.CExtensionUtils.addDisableClockSyncCompileDefinitions ( FederateInstance federate)
static

◆ clockSyncIsOn()

boolean org.lflang.federated.extensions.CExtensionUtils.clockSyncIsOn ( FederateInstance federate,
RtiConfig rtiConfig )
staticpackage

◆ createPortStatusFieldForInput()

String org.lflang.federated.extensions.CExtensionUtils.createPortStatusFieldForInput ( Input input)
static

Create a port status field variable for a network input port "input" in the self struct of a reactor.

Parameters
inputThe network input port
Returns
A string containing the appropriate variable

◆ generateCMakeInclude()

void org.lflang.federated.extensions.CExtensionUtils.generateCMakeInclude ( FederateInstance federate,
FederationFileConfig fileConfig ) throws IOException
static

Generate a file to be included by CMake.

◆ generateFederateNeighborStructure()

String org.lflang.federated.extensions.CExtensionUtils.generateFederateNeighborStructure ( FederateInstance federate)
static

Generate code that sends the neighbor structure message to the RTI.

See MSG_TYPE_NEIGHBOR_STRUCTURE in federated/net_common.h.

Parameters
federateThe federate that is sending its neighbor structure

◆ generateSerializationCMakeExtension()

String org.lflang.federated.extensions.CExtensionUtils.generateSerializationCMakeExtension ( FederateInstance federate)
static

Generate cmake-include code needed for enabled serializers of the federate.

◆ generateSerializationIncludes()

String org.lflang.federated.extensions.CExtensionUtils.generateSerializationIncludes ( FederateInstance federate)
static

Generate preamble code needed for enabled serializers of the federate.

◆ getNetworkDelayLiteral()

String org.lflang.federated.extensions.CExtensionUtils.getNetworkDelayLiteral ( Expression delay)
static

Given a connection 'delay' expression, return a string that represents the interval_t value of the additional delay that needs to be applied to the outgoing message.

The returned additional delay in absence of after on network connection (i.e., if delay is passed as a null) is NEVER. This has a special meaning in C library functions that send network messages that carry timestamps (

See also
lf_send_tagged_message and lf_send_port_absent_to_federate in lib/core/federate.c). In this case, the sender will send its current tag as the timestamp of the outgoing message without adding a microstep delay. If the user has assigned an after delay to the network connection (that can be zero) either as a time value (e.g., 200 msec) or as a literal (e.g., a parameter), that delay in nsec will be returned.
Parameters
delayThe delay associated with a connection.

◆ handleCompileDefinitions()

void org.lflang.federated.extensions.CExtensionUtils.handleCompileDefinitions ( FederateInstance federate,
List< String > federateNames,
RtiConfig rtiConfig,
MessageReporter messageReporter )
static

◆ initializeClockSynchronization()

void org.lflang.federated.extensions.CExtensionUtils.initializeClockSynchronization ( FederateInstance federate,
RtiConfig rtiConfig,
MessageReporter messageReporter )
static

Initialize clock synchronization (if enabled) and its related options for a given federate.

Clock synchronization can be enabled using the clock-sync target property.

See also
Documentation

◆ initializeTriggersForNetworkActions()

String org.lflang.federated.extensions.CExtensionUtils.initializeTriggersForNetworkActions ( FederateInstance federate,
ReactorInstance main )
static

Generate C code that initializes network actions.

These network actions will be triggered by federate.c whenever a message is received from the network.

Parameters
federateThe federate.
mainThe main reactor that contains the federate (used to lookup references).

◆ isSharedPtrType()

boolean org.lflang.federated.extensions.CExtensionUtils.isSharedPtrType ( InferredType type,
CTypes types )
staticpackage

◆ stpStructs()

String org.lflang.federated.extensions.CExtensionUtils.stpStructs ( FederateInstance federate)
static

Generate C code that holds a sorted list of STAA structs by time.

For decentralized execution, on every logical timestep, a thread will iterate through each staa struct, wait for the designated offset time, and set the associated port status to absent if it isn't known.

Parameters
federateThe federate.

◆ surroundWithIfElseFederated()

String org.lflang.federated.extensions.CExtensionUtils.surroundWithIfElseFederated ( String insideIf,
String insideElse )
static

◆ surroundWithIfElseFederatedCentralized()

String org.lflang.federated.extensions.CExtensionUtils.surroundWithIfElseFederatedCentralized ( String insideIf,
String insideElse )
static

◆ surroundWithIfFederated()

String org.lflang.federated.extensions.CExtensionUtils.surroundWithIfFederated ( String code)
static

Surround code with blocks to ensure that code only executes if the program is federated.

◆ surroundWithIfFederatedCentralized()

String org.lflang.federated.extensions.CExtensionUtils.surroundWithIfFederatedCentralized ( String code)
static

Surround code with blocks to ensure that code only executes if the program is federated and has a centralized coordination.

◆ surroundWithIfFederatedDecentralized()

String org.lflang.federated.extensions.CExtensionUtils.surroundWithIfFederatedDecentralized ( String code)
static

Surround code with blocks to ensure that code only executes if the program is federated and has a decentralized coordination.

Member Data Documentation

◆ sharedPointerVariable

final Pattern org.lflang.federated.extensions.CExtensionUtils.sharedPointerVariable
staticpackage
Initial value:
=
Pattern.compile("^(/\\*.*?\\*/)?std::shared_ptr<(?<type>((/\\*.*?\\*/)?(\\S+))+)>$")

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/extensions/CExtensionUtils.java