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

An extension class to the PythonGenerator that enables certain federated functionalities. More...

Inherits org.lflang.federated.extensions.CExtension.

Public Member Functions

void addSenderIndexParameter (Reactor sender)
 Generate code for the parameter that specifies the sender index.
void annotateReaction (Reaction reaction)
 Optionally apply additional annotations to the reaction.
String generateNetworkReceiverBody (Action action, VarRef sendingPort, VarRef receivingPort, FedConnectionInstance connection, InferredType type, CoordinationMode coordinationMode, MessageReporter messageReporter)
 Generate code for the body of a reaction that handles the action that is triggered by receiving a message from a remote federate.
String generateNetworkSenderBody (VarRef sendingPort, VarRef receivingPort, FedConnectionInstance connection, InferredType type, CoordinationMode coordinationMode, MessageReporter messageReporter)
 Generate code for the body of a reaction that handles an output that is to be sent over the network.
String generatePortAbsentReactionBody (VarRef srcOutputPort, FedConnectionInstance connection)
 Generate code for the body of a reaction that sends a port status message for the given port if it is absent.
String generatePreamble (FederateInstance federate, FederationFileConfig fileConfig, RtiConfig rtiConfig, MessageReporter messageReporter) throws IOException
 Add preamble to a separate file to set up federated execution.
String getNetworkBufferType ()
 Return the type for the raw network buffer in the target language (e.g., uint_8 in C).
void initializeTargetConfig (LFGeneratorContext context, List< String > federateNames, FederateInstance federate, FederationFileConfig fileConfig, MessageReporter messageReporter, RtiConfig rtiConfig) throws IOException
 Perform necessary actions to initialize the target config.
String outputInitializationBody ()
 Generate code for initializing a network output reactor from its startup reaction.
void supplySenderIndexParameter (Instantiation inst, int idx)
 Generate code for the sender index argument of instantiation.

Protected Member Functions

void deserialize (Action action, VarRef receivingPort, FedConnectionInstance connection, InferredType type, String receiveRef, CodeBuilder result, MessageReporter messageReporter)
 Generate code to deserialize a message received over the network.
void generateCMakeInclude (FederateInstance federate, FederationFileConfig fileConfig) throws IOException
 Generate a cmake-include file for federate if needed.
String generateSerializationIncludes (FederateInstance federate, FederationFileConfig fileConfig)
 Generate preamble code needed for enabled serializers of the federate.
void serializeAndSend (FedConnectionInstance connection, InferredType type, String sendRef, CodeBuilder result, String sendingFunction, String commonArgs, MessageReporter messageReporter)
 Generate code for serializing data and sending it over the given connection.
final void writePreambleFile (FederateInstance federate, FederationFileConfig fileConfig, RtiConfig rtiConfig, MessageReporter messageReporter) throws IOException
 Put the C preamble in a include/_federate.name + _preamble.h file.

Detailed Description

An extension class to the PythonGenerator that enables certain federated functionalities.

Author
Soroush Bateni

Member Function Documentation

◆ addSenderIndexParameter()

void org.lflang.federated.extensions.CExtension.addSenderIndexParameter ( Reactor sender)
inherited

Generate code for the parameter that specifies the sender index.

Implements org.lflang.federated.extensions.FedTargetExtension.

◆ annotateReaction()

void org.lflang.federated.extensions.PythonExtension.annotateReaction ( Reaction reaction)

Optionally apply additional annotations to the reaction.

Implements org.lflang.federated.extensions.FedTargetExtension.

◆ deserialize()

void org.lflang.federated.extensions.PythonExtension.deserialize ( Action action,
VarRef receivingPort,
FedConnectionInstance connection,
InferredType type,
String receiveRef,
CodeBuilder result,
MessageReporter messageReporter )
protected

Generate code to deserialize a message received over the network.

Parameters
actionThe network action that is mapped to the receivingPort
receivingPortThe receiving port
connectionThe connection used to receive the message
typeType for the port
receiveRefA target language reference to the receiving port
resultUsed to put generated code in
messageReporterUsed to report errors, if any

Reimplemented from org.lflang.federated.extensions.CExtension.

◆ generateCMakeInclude()

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

Generate a cmake-include file for federate if needed.

Reimplemented from org.lflang.federated.extensions.CExtension.

◆ generateNetworkReceiverBody()

String org.lflang.federated.extensions.PythonExtension.generateNetworkReceiverBody ( Action action,
VarRef sendingPort,
VarRef receivingPort,
FedConnectionInstance connection,
InferredType type,
CoordinationMode coordinationMode,
MessageReporter messageReporter )

Generate code for the body of a reaction that handles the action that is triggered by receiving a message from a remote federate.

Parameters
actionThe action.
sendingPortThe output port providing the data to send.
receivingPortThe ID of the destination port.
connectionThe federated connection being lowered.
typeThe type of the data conveyed by the port.
coordinationModeThe coordination type
messageReporterUsed to report errors and warnings.

Reimplemented from org.lflang.federated.extensions.CExtension.

◆ generateNetworkSenderBody()

String org.lflang.federated.extensions.PythonExtension.generateNetworkSenderBody ( VarRef sendingPort,
VarRef receivingPort,
FedConnectionInstance connection,
InferredType type,
CoordinationMode coordinationMode,
MessageReporter messageReporter )

Generate code for the body of a reaction that handles an output that is to be sent over the network.

Parameters
sendingPortThe output port providing the data to send.
receivingPortThe variable reference to the destination port.
connectionThe federated connection being lowered.
typeThe type of the data conveyed by the connection.
coordinationModeCentralized or decentralized.
messageReporterUsed to report errors and warnings.

Reimplemented from org.lflang.federated.extensions.CExtension.

◆ generatePortAbsentReactionBody()

String org.lflang.federated.extensions.CExtension.generatePortAbsentReactionBody ( VarRef srcOutputPort,
FedConnectionInstance connection )
inherited

Generate code for the body of a reaction that sends a port status message for the given port if it is absent.

Parameters
srcOutputPortA reference to the port that the sender reaction reads from.
connectionThe federated connection being lowered.

Implements org.lflang.federated.extensions.FedTargetExtension.

◆ generatePreamble()

String org.lflang.federated.extensions.PythonExtension.generatePreamble ( FederateInstance federate,
FederationFileConfig fileConfig,
RtiConfig rtiConfig,
MessageReporter messageReporter ) throws IOException

Add preamble to a separate file to set up federated execution.

Return an a string containing the #include directives that are needed by the federate.

Reimplemented from org.lflang.federated.extensions.CExtension.

◆ generateSerializationIncludes()

String org.lflang.federated.extensions.PythonExtension.generateSerializationIncludes ( FederateInstance federate,
FederationFileConfig fileConfig )
protected

Generate preamble code needed for enabled serializers of the federate.

Reimplemented from org.lflang.federated.extensions.CExtension.

◆ getNetworkBufferType()

String org.lflang.federated.extensions.PythonExtension.getNetworkBufferType ( )

Return the type for the raw network buffer in the target language (e.g., uint_8 in C).

This would be the type of the network messages after serialization and before deserialization. It is primarily used to determine the type for the network action at the receiver.

Reimplemented from org.lflang.federated.extensions.CExtension.

◆ initializeTargetConfig()

void org.lflang.federated.extensions.CExtension.initializeTargetConfig ( LFGeneratorContext context,
List< String > federateNames,
FederateInstance federate,
FederationFileConfig fileConfig,
MessageReporter messageReporter,
RtiConfig rtiConfig ) throws IOException
inherited

Perform necessary actions to initialize the target config.

Parameters
contextThe context of the original code generation process.
federateNamesThe names of all the federates in the program.
federateThe federate instance.
fileConfigAn instance of FedFileConfig.
messageReporterUsed to report errors.
rtiConfigThe RTI configuration settings.

Implements org.lflang.federated.extensions.FedTargetExtension.

◆ outputInitializationBody()

String org.lflang.federated.extensions.CExtension.outputInitializationBody ( )
inherited

Generate code for initializing a network output reactor from its startup reaction.

Implements org.lflang.federated.extensions.FedTargetExtension.

◆ serializeAndSend()

void org.lflang.federated.extensions.PythonExtension.serializeAndSend ( FedConnectionInstance connection,
InferredType type,
String sendRef,
CodeBuilder result,
String sendingFunction,
String commonArgs,
MessageReporter messageReporter )
protected

Generate code for serializing data and sending it over the given connection.

Parameters
connectionA federated connection.
typeThe type of the data sent on the connection.
sendRefC code representing a reference to the data to be sent.
resultAn accumulator of the generated code.
sendingFunctionThe name of the function that sends the serialized data.
commonArgsArguments passed to sendingFunction regardless of serialization method.
messageReporterUsed to report errors and warnings.

Reimplemented from org.lflang.federated.extensions.CExtension.

◆ supplySenderIndexParameter()

void org.lflang.federated.extensions.CExtension.supplySenderIndexParameter ( Instantiation inst,
int idx )
inherited

Generate code for the sender index argument of instantiation.

Implements org.lflang.federated.extensions.FedTargetExtension.

◆ writePreambleFile()

final void org.lflang.federated.extensions.CExtension.writePreambleFile ( FederateInstance federate,
FederationFileConfig fileConfig,
RtiConfig rtiConfig,
MessageReporter messageReporter ) throws IOException
protectedinherited

Put the C preamble in a include/_federate.name + _preamble.h file.


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