![]() |
lingua-franca 0.10.1
Lingua Franca code generator
|
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. | |
An extension class to the PythonGenerator that enables certain federated functionalities.
|
inherited |
Generate code for the parameter that specifies the sender index.
Implements org.lflang.federated.extensions.FedTargetExtension.
| void org.lflang.federated.extensions.PythonExtension.annotateReaction | ( | Reaction | reaction | ) |
Optionally apply additional annotations to the reaction.
Implements org.lflang.federated.extensions.FedTargetExtension.
|
protected |
Generate code to deserialize a message received over the network.
| action | The network action that is mapped to the receivingPort |
| receivingPort | The receiving port |
| connection | The connection used to receive the message |
| type | Type for the port |
| receiveRef | A target language reference to the receiving port |
| result | Used to put generated code in |
| messageReporter | Used to report errors, if any |
Reimplemented from org.lflang.federated.extensions.CExtension.
|
protected |
Generate a cmake-include file for federate if needed.
Reimplemented from org.lflang.federated.extensions.CExtension.
| 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.
| action | The action. |
| sendingPort | The output port providing the data to send. |
| receivingPort | The ID of the destination port. |
| connection | The federated connection being lowered. |
| type | The type of the data conveyed by the port. |
| coordinationMode | The coordination type |
| messageReporter | Used to report errors and warnings. |
Reimplemented from org.lflang.federated.extensions.CExtension.
| 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.
| sendingPort | The output port providing the data to send. |
| receivingPort | The variable reference to the destination port. |
| connection | The federated connection being lowered. |
| type | The type of the data conveyed by the connection. |
| coordinationMode | Centralized or decentralized. |
| messageReporter | Used to report errors and warnings. |
Reimplemented from org.lflang.federated.extensions.CExtension.
|
inherited |
Generate code for the body of a reaction that sends a port status message for the given port if it is absent.
| srcOutputPort | A reference to the port that the sender reaction reads from. |
| connection | The federated connection being lowered. |
Implements org.lflang.federated.extensions.FedTargetExtension.
| 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.
|
protected |
Generate preamble code needed for enabled serializers of the federate.
Reimplemented from org.lflang.federated.extensions.CExtension.
| 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.
|
inherited |
Perform necessary actions to initialize the target config.
| context | The context of the original code generation process. |
| federateNames | The names of all the federates in the program. |
| federate | The federate instance. |
| fileConfig | An instance of FedFileConfig. |
| messageReporter | Used to report errors. |
| rtiConfig | The RTI configuration settings. |
Implements org.lflang.federated.extensions.FedTargetExtension.
|
inherited |
Generate code for initializing a network output reactor from its startup reaction.
Implements org.lflang.federated.extensions.FedTargetExtension.
|
protected |
Generate code for serializing data and sending it over the given connection.
| connection | A federated connection. |
| type | The type of the data sent on the connection. |
| sendRef | C code representing a reference to the data to be sent. |
| result | An accumulator of the generated code. |
| sendingFunction | The name of the function that sends the serialized data. |
| commonArgs | Arguments passed to sendingFunction regardless of serialization method. |
| messageReporter | Used to report errors and warnings. |
Reimplemented from org.lflang.federated.extensions.CExtension.
|
inherited |
Generate code for the sender index argument of instantiation.
Implements org.lflang.federated.extensions.FedTargetExtension.
|
protectedinherited |
Put the C preamble in a include/_federate.name + _preamble.h file.