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

Generate Python code for reactions. More...

Static Public Member Functions

static String generateCPythonDeadlineCaller (TypeParameterizedReactor r, int reactionIndex, List< String > pyObjects)
 Generate code to call deadline function numbered "reactionIndex" in reactor "r".
static String generateCPythonDeadlineFunctionName (int reactionIndex)
 Return the function name of the deadline function inside the self struct in the .c file.
static String generateCPythonReactionCaller (TypeParameterizedReactor reactor, int reactionIndex, List< String > pyObjects, String inits)
 Generate code to call reaction numbered "reactionIndex" in reactor "reactor".
static String generateCPythonReactionFunctionName (int reactionIndex)
 Return the function name of the reaction inside the self struct in the .c file.
static String generateCPythonReactionLinker (ReactorInstance instance, ReactionInstance reaction, String nameOfSelfStruct)
 Generate Python code to link cpython functions to python functions for a reaction.
static String generateCPythonReactionLinkers (ReactorInstance instance, Instantiation mainDef)
 Generate Python code to link cpython functions to python functions for each reaction.
static String generateCPythonSTPCaller (TypeParameterizedReactor r, int reactionIndex, List< String > pyObjects)
 Generate code to call deadline function numbered "reactionIndex" in reactor "r".
static String generateCPythonSTPFunctionName (int reactionIndex)
 Return the function name of the STP violation handler function inside the self struct in the .c file.
static String generateCReaction (Reaction reaction, TypeParameterizedReactor tpr, Reactor r, int reactionIndex, Instantiation mainDef, MessageReporter messageReporter, CTypes types)
 Generate the reaction in the .c file, which calls the Python reaction through the CPython interface.
static String generateFunction (String header, String init, Code code, String pyCaller)
static String generatePythonDeadlineFunctionName (int reactionIndex)
 Return the function name of the deadline function in the .py file.
static String generatePythonFunction (String pythonFunctionName, String inits, String reactionBody, List< String > reactionParameters)
 Generate the function that is executed whenever the deadline of the reaction with the given reaction index is missed.
static String generatePythonReaction (Reactor reactor, Reaction reaction, int reactionIndex)
 Generate the Python code for reaction in reactor.
static String generatePythonReactionFunctionName (int reactionIndex)
 Return the function name of the reaction in the .py file.
static void generatePythonReactionParametersAndInitializations (List< String > parameters, CodeBuilder inits, ReactorDecl decl, Reaction reaction)
 Generate parameters and their respective initialization code for a reaction function The initialization code is put at the beginning of the reaction before user code.
static String generatePythonReactions (Reactor reactor, List< Reaction > reactions)
 Generate the Python code for reactions in reactor.
static String generatePythonSTPFunctionName (int reactionIndex)
 Return the function name of the STP violation handler function in the .py file.

Detailed Description

Generate Python code for reactions.

Member Function Documentation

◆ generateCPythonDeadlineCaller()

String org.lflang.generator.python.PythonReactionGenerator.generateCPythonDeadlineCaller ( TypeParameterizedReactor r,
int reactionIndex,
List< String > pyObjects )
static

Generate code to call deadline function numbered "reactionIndex" in reactor "r".

Parameters
rThe reactor containing the reaction
reactionIndexThe index of the reaction
pyObjectsCPython related objects

◆ generateCPythonDeadlineFunctionName()

String org.lflang.generator.python.PythonReactionGenerator.generateCPythonDeadlineFunctionName ( int reactionIndex)
static

Return the function name of the deadline function inside the self struct in the .c file.

Parameters
reactionIndexThe reaction index.
Returns
The function name for the reaction.

◆ generateCPythonReactionCaller()

String org.lflang.generator.python.PythonReactionGenerator.generateCPythonReactionCaller ( TypeParameterizedReactor reactor,
int reactionIndex,
List< String > pyObjects,
String inits )
static

Generate code to call reaction numbered "reactionIndex" in reactor "reactor".

Parameters
reactorThe reactor containing the reaction
reactionIndexThe index of the reaction
pyObjectsCPython related objects
initsInitialization code.

◆ generateCPythonReactionFunctionName()

String org.lflang.generator.python.PythonReactionGenerator.generateCPythonReactionFunctionName ( int reactionIndex)
static

Return the function name of the reaction inside the self struct in the .c file.

Parameters
reactionIndexThe reaction index.
Returns
The function name for the reaction.

◆ generateCPythonReactionLinker()

String org.lflang.generator.python.PythonReactionGenerator.generateCPythonReactionLinker ( ReactorInstance instance,
ReactionInstance reaction,
String nameOfSelfStruct )
static

Generate Python code to link cpython functions to python functions for a reaction.

Parameters
instanceThe reactor instance.
reactionThe reaction of this instance to link.
nameOfSelfStructThe name of the self struct in cpython.

◆ generateCPythonReactionLinkers()

String org.lflang.generator.python.PythonReactionGenerator.generateCPythonReactionLinkers ( ReactorInstance instance,
Instantiation mainDef )
static

Generate Python code to link cpython functions to python functions for each reaction.

Parameters
instanceThe reactor instance.
mainDefThe definition of the main reactor

◆ generateCPythonSTPCaller()

String org.lflang.generator.python.PythonReactionGenerator.generateCPythonSTPCaller ( TypeParameterizedReactor r,
int reactionIndex,
List< String > pyObjects )
static

Generate code to call deadline function numbered "reactionIndex" in reactor "r".

Parameters
rThe reactor containing the reaction
reactionIndexThe index of the reaction
pyObjectsCPython related objects

◆ generateCPythonSTPFunctionName()

String org.lflang.generator.python.PythonReactionGenerator.generateCPythonSTPFunctionName ( int reactionIndex)
static

Return the function name of the STP violation handler function inside the self struct in the .c file.

Parameters
reactionIndexThe reaction index.
Returns
The function name for the reaction.

◆ generateCReaction()

String org.lflang.generator.python.PythonReactionGenerator.generateCReaction ( Reaction reaction,
TypeParameterizedReactor tpr,
Reactor r,
int reactionIndex,
Instantiation mainDef,
MessageReporter messageReporter,
CTypes types )
static

Generate the reaction in the .c file, which calls the Python reaction through the CPython interface.

Parameters
reactionThe reaction to generate Python-specific initialization for.
tprThe type-parameterized reactor.
rThe reactor to which reaction belongs to.
reactionIndexThe index number of the reaction in decl.
mainDefThe main reactor.
messageReporterAn error reporter.
typesA helper class for type-related stuff.

◆ generateFunction()

String org.lflang.generator.python.PythonReactionGenerator.generateFunction ( String header,
String init,
Code code,
String pyCaller )
static

◆ generatePythonDeadlineFunctionName()

String org.lflang.generator.python.PythonReactionGenerator.generatePythonDeadlineFunctionName ( int reactionIndex)
static

Return the function name of the deadline function in the .py file.

Parameters
reactionIndexThe reaction index.
Returns
The function name for the reaction.

◆ generatePythonFunction()

String org.lflang.generator.python.PythonReactionGenerator.generatePythonFunction ( String pythonFunctionName,
String inits,
String reactionBody,
List< String > reactionParameters )
static

Generate the function that is executed whenever the deadline of the reaction with the given reaction index is missed.

Parameters
pythonFunctionNameThe name of the Python function.
initsInitialization code.
reactionBodyThe body of the reaction.
reactionParametersThe parameters to the deadline violation function, which are the same as the reaction function

◆ generatePythonReaction()

String org.lflang.generator.python.PythonReactionGenerator.generatePythonReaction ( Reactor reactor,
Reaction reaction,
int reactionIndex )
static

Generate the Python code for reaction in reactor.

Parameters
reactorThe reactor
reactionThe reaction of reactor
reactionIndexThe index of the reaction.

◆ generatePythonReactionFunctionName()

String org.lflang.generator.python.PythonReactionGenerator.generatePythonReactionFunctionName ( int reactionIndex)
static

Return the function name of the reaction in the .py file.

Parameters
reactionIndexThe reaction index.
Returns
The function name for the reaction.

◆ generatePythonReactionParametersAndInitializations()

void org.lflang.generator.python.PythonReactionGenerator.generatePythonReactionParametersAndInitializations ( List< String > parameters,
CodeBuilder inits,
ReactorDecl decl,
Reaction reaction )
static

Generate parameters and their respective initialization code for a reaction function The initialization code is put at the beginning of the reaction before user code.

Parameters
parametersThe parameters used for function definition
initsThe initialization code for those paramters
declReactor declaration
reactionThe reaction to be used to generate parameters for

◆ generatePythonReactions()

String org.lflang.generator.python.PythonReactionGenerator.generatePythonReactions ( Reactor reactor,
List< Reaction > reactions )
static

Generate the Python code for reactions in reactor.

Parameters
reactorThe reactor
reactionsThe reactions of reactor

◆ generatePythonSTPFunctionName()

String org.lflang.generator.python.PythonReactionGenerator.generatePythonSTPFunctionName ( int reactionIndex)
static

Return the function name of the STP violation handler function in the .py file.

Parameters
reactionIndexThe reaction index.
Returns
The function name for the reaction.

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/python/PythonReactionGenerator.java