public class WriterCodegen
extends java.lang.Object
#readTpl(Class, String)
.
Depending of the data structure different otx scripts are called.
With the otx scripts the adaption to any target language can be done, and also to any desired style.
The otx scripts are able to give from outside. The adaption can be done without changing the Java sources
and also without study the Java sources.
writeCode(File, File, String, Module_FBcl, LogMessage)
.
This operation writes all defined output files.
General the script for the whole output file for a target language starts with:Modifier and Type | Class and Description |
---|---|
protected static class |
WriterCodegen.CondNode
Contains data saved in a stack for next sibling node after a condition node.
|
static class |
WriterCodegen.OtxWorkData |
(package private) static class |
WriterCodegen.XXXECondCode |
Modifier and Type | Field and Description |
---|---|
boolean |
bVerboseCode |
java.lang.Class<FBaccess_FBcl> |
class_FBaccess_FBcl
Used for quest '?
|
java.util.Map<java.lang.String,java.lang.String> |
cmprOp
Map operators of OFB (compatible IEC61499) to target language C/++, Java
Note due IEC61499 '=' is equal and '<>' is not equal from graphic
|
java.util.Map<java.lang.String,java.lang.String> |
cmprOpReverse
Note '>' is translated to '<=' etc. because the relation is to the input,
but the operator is written left side, regarded als compare between left and this value.
|
(package private) java.util.Map<java.lang.String,java.lang.Object> |
idxConstData
This map can be filled by the script especially with String-String associations.
|
(package private) java.util.Map<java.lang.String,org.vishia.util.OutTextPreparer.DataTextPreparer> |
idxOtdata |
(package private) java.util.TreeMap<java.lang.String,org.vishia.util.OutTextPreparer> |
idxOtx
Index with all scripts to write, filled after creation of this class calling
#readTpl(Class, String) . |
static java.util.List<Din_FBcl> |
iterDinEmpty
Is used for the first evChain entry, it has the module din.
|
java.util.Map<java.lang.String,java.lang.String> |
numOp |
java.util.Map<java.lang.String,java.lang.String> |
numOpFirst |
(package private) org.vishia.util.OutTextPreparer |
otx_defineLocalVar_FBexpr
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otx_evMdlOutEnd
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otx_evMdlOutStart
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otx_exprCondBitsIf
Called if a condition bit change is found.
|
(package private) org.vishia.util.OutTextPreparer |
otx_exprCondIf
Called if an event output true is found.
|
(package private) org.vishia.util.OutTextPreparer |
otx_setMdlOutArrayCpy
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otx_setMdlOutArrayExpr
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otx_setMdlOutScalar
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otx_setMdlOutStructCpy
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otx_setVar_FBexpr
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otx_setVarArrayElem
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otx_setVarStruct
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otx_setVarX_Array
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otx_setVarX_Elem
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otxAccessFBdout
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otxCallFB_evin
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otxCtorFB_evin
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otxCtorObjFB_evin
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otxEvChainExprSetvar
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otxExprAccessElement
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otxExprCondBitsEndif
Called if a condition bit change is found.
|
(package private) org.vishia.util.OutTextPreparer |
otxExprElse
Called if an event output true is found.
|
(package private) org.vishia.util.OutTextPreparer |
otxExprEndif
Called if the chain of an event output true is finished,
means the next event given before executing the "true" is found, or on end of all events.
|
(package private) org.vishia.util.OutTextPreparer |
otxExprEv_OFB_Variable
Called if an event output true is found.
|
(package private) org.vishia.util.OutTextPreparer |
otxExprIf
Called if an event output true is found.
|
(package private) org.vishia.util.OutTextPreparer |
otxExprTerm
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) org.vishia.util.OutTextPreparer |
otxInitFB_evin
This is the important OutTextPreparer for one event chain member proper to
#prcEvChain(Evin_FBcl, Integer, Writer) . |
(package private) Prj_FBCLrd |
prj |
(package private) java.lang.String |
sDbgFBexpr |
(package private) java.lang.String |
sDbgFBexprEvin |
java.lang.String |
sNewlineIndent |
(package private) java.lang.String |
testData |
java.util.Map<java.lang.String,java.lang.String> |
unaryOp |
static java.lang.String |
version
Version, history and license.
|
(package private) org.vishia.util.OutTextPreparer |
XXXotx_exprSetCond
Called if an event output true is found.
|
Constructor and Description |
---|
WriterCodegen(Prj_FBCLrd prj) |
Modifier and Type | Method and Description |
---|---|
private void |
callFBoper(FBexpr_FBcl fbx,
long[] condBits,
Dout_FBcl dout,
WriterCodegen.OtxWorkData wd,
java.lang.Appendable wr)
Generates the code for a called operation of an FBexpr as FBoper if it contains a
FBexpr_FBcl.getFunction() . |
boolean |
checkSetLocalVariable(java.lang.String name,
WriterCodegen.OtxWorkData wd) |
void |
doInsert(WriterCodegen.OtxWorkData wd,
java.lang.StringBuilder OUT) |
private void |
genAccessGet(Dout_FBcl doutAccess,
long[] condBits,
FBaccess_FBcl fba,
java.lang.String ref,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
java.lang.StringBuilder sb,
int recursion)
Generates the term due to the given expression.
|
java.lang.String |
genDinAccess(Din_FBcl din,
PinConnect_FBcl conn,
long[] condBits,
java.lang.String sVariant,
java.lang.String ref,
int ix,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
java.lang.StringBuilder out)
Generates the access String for an input of any FBlock.
|
void |
genDinAccessConn(Din_FBcl din,
PinConnect_FBcl connSrc,
java.lang.String cacc,
long[] condBits,
java.lang.String ref,
WriterCodegen.OtxWorkData wd,
java.lang.StringBuilder out)
Generates the code for a given
Din_FBcl for a given connection PinConnect_FBcl |
private void |
genExprIn(DinExpr_FBcl din,
FBexpr_FBcl fbx,
long[] condBits,
java.lang.String sOperatorLeftArg,
java.lang.String sOperator,
java.lang.String sUnaryOp,
java.lang.String ref,
int ix,
java.lang.String caccArg,
WriterCodegen.OtxWorkData wd,
java.lang.StringBuilder sb,
int recursion)
Generate the code of an expression input regarding constant values and K parts.
|
private void |
genExprOut(Dout_FBcl doutExpr,
java.lang.String selDinElemDst,
FBexpr_FBcl fbx,
long[] condBits,
java.lang.String ref,
int ix,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
java.lang.StringBuilder sb,
int recursion)
Generates the term due to the given expression.
|
private void |
genExprTerm(java.lang.StringBuilder sb,
java.lang.String selDinElemDst,
FBexpr_FBcl fbx,
long[] condBits,
java.lang.String ref,
int ix,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
int recursion)
Generates an expression determined by its inputs with its operators and K inputs.
|
private void |
genExprTermCmpr(java.lang.StringBuilder sb,
java.lang.String selDinElemDst,
FBexpr_FBcl fbx,
java.lang.Iterable<DinExpr_FBcl> dinValues,
long[] condBits,
java.lang.String ref,
int ix,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
int recursion) |
java.lang.String |
genRefIn(PinRef_FBcl din,
long[] condBits,
java.lang.String ref,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
java.lang.StringBuilder out,
int recursion)
Generates the access String for a reference of a FBlock for direct connected port output.
|
java.lang.String |
genValueDin(Din_FBcl din,
long[] condBits,
java.lang.String ref,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd)
Generates the access String for an input of a FBlock maybe through some combinatoric expressions.
|
void |
genValueDout(Dout_FBcl dout,
long[] condBits,
java.lang.String ref,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
java.lang.StringBuilder sb,
int recursion)
Generates the access String to data from the given output pin of any
FBlock_FBcl , also an FBexpr_FBcl or a Variable after expression. |
void |
genVarAccessSet(Dout_FBcl doutVar,
Dout_FBcl doutExpr,
FBaccess_FBcl fba,
long[] condBits,
java.lang.String varAcc,
WriterCodegen.OtxWorkData wd,
java.lang.CharSequence nli,
java.lang.StringBuilder sb) |
void |
genVarExpr(Dout_FBcl doutVar,
Dout_FBcl doutExpr,
FBlock_FBcl fb,
long[] condBits,
java.lang.String ref,
int ix,
java.lang.String cacc,
WriterCodegen.OtxWorkData wd,
java.lang.StringBuilder sb)
Called in otx (VarX_OFB) to set the variable after expression or access.
|
void |
genVariableDef(Module_FBcl mdl,
WriterCodegen.OtxWorkData wd,
java.lang.Appendable out)
Generates a proper code for variable definitions (usual in header file) for all variables on output on expressions.
|
(package private) org.vishia.util.OutTextPreparer.DataTextPreparer |
getCreateOtxData(org.vishia.util.OutTextPreparer otx,
WriterCodegen.OtxWorkData wd)
Gets the proper instance of DataTextPreparer to run
OutTextPreparer.exec(Appendable, org.vishia.util.OutTextPreparer.DataTextPreparer)
running repeatedly in the same thread. |
void |
insertPoint(WriterCodegen.OtxWorkData wd,
java.lang.StringBuilder OUT) |
static java.lang.Iterable<java.lang.Integer> |
iterBits(long[] bitArray) |
void |
parseScripts(org.vishia.msgDispatch.LogMessage log)
Translates the script to otx, second pass of translation
It translates
idxOtx and set otxCallFB_evin . |
private void |
prc_setVar_FBexpr(FBexpr_FBcl fbx,
Evout_FBcl evSrc,
Evin_FBcl evinDst,
Dout_FBcl doutExpr,
Dinout_FBcl varExpr,
java.util.List<Dout_FBcl> listVarOut,
long[] condBits,
WriterCodegen.OtxWorkData wd,
java.lang.Appendable out)
Generates code for the input event of an expression which is immediately before a variable.
|
void |
prcEvchainOperation(EvtreeNode_FBcl nodeRoot,
Evout_FBcl evStartArg,
Module_FBcl mdl,
WriterCodegen.OtxWorkData wd,
java.lang.Appendable out)
This operation follows the
EvtreeNode_FBcl from evStart to generate the code for this event as operation. |
private void |
prcEvinFBaccess(Evout_FBcl evSrc,
Evin_FBcl evinDst,
long[] condBits,
WriterCodegen.OtxWorkData wd,
java.lang.Appendable wr)
Process the next FBlock as FBaccess.
|
private void |
prcEvinFBexpr(Evout_FBcl evSrc,
Evin_FBcl evinDst,
long[] condBits,
WriterCodegen.OtxWorkData wd,
java.lang.Appendable wr)
Process the next FBlock as FBexpr.
|
private void |
prcEvinFBlock(Evout_FBcl evinMdl,
Evout_FBcl evoutSrc,
Evin_FBcl evinDst,
long[] condBitsSrc,
java.lang.String sVariant,
WriterCodegen.OtxWorkData wd,
Module_FBcl mdl,
java.lang.Appendable out)
Processes one evin to one FBlock.
|
private void |
prcEvNode(Evout_FBcl evinMdl,
EvtreeNode_FBcl evNode,
long[] condBitsSrc,
EvtreeNode_FBcl.IteratorEvoutTree iterTree,
Module_FBcl mdl,
WriterCodegen.OtxWorkData wd,
java.lang.Appendable out,
int recursion)
Generates the code due to one
EvtreeNode_FBcl called in prcEvchainOperation(EvtreeNode_FBcl, Evout_FBcl, Module_FBcl, OtxWorkData, Appendable)
following the event node chain. |
private void |
prcEvNodesBranch(Evout_FBcl evinMdl,
EvtreeNode_FBcl evNode,
Evout_FBcl evoutSrc,
Evin_FBcl XXXevin,
long[][] condBits,
int ixCond,
WriterCodegen.OtxWorkData wd,
Module_FBcl mdl,
java.lang.Appendable out,
int recursion) |
private void |
prepareExprTextGiven(java.lang.StringBuilder out,
FBexpr_FBcl fbx,
long[] condBits,
java.lang.String ref,
java.lang.String sFn,
WriterCodegen.OtxWorkData wd)
Prepares any expression which is given in sFn.
|
void |
readTpl(java.lang.Class<?> classInJar,
java.lang.String pathTpl,
org.vishia.msgDispatch.LogMessage log)
Reads the script file in the first pass
It fills
idxOtx with empty instances of otx. |
private boolean |
testCondition(Din_FBcl din,
long[] condBits)
Test whether the given condition is met on any of the source pins if more connections are given.
|
private boolean |
testCondition(Dout_FBcl doutSrc,
long[] condBits)
Test whether the condition is true for the given source pin.
|
private java.lang.String |
translateOperatorToTargetLang(char dType,
java.lang.String sGraphicOperator,
java.util.Map<java.lang.String,java.lang.String> idxTrl,
java.lang.String sDefault)
check whether graphic operator with specific type should be translated.
|
void |
writeCode(java.io.File dirout,
java.io.File dirCmp,
java.lang.String sMdlName,
Module_FBcl mdl,
org.vishia.msgDispatch.LogMessage log)
General call of the write code for one output file with the scripts.
|
public static final java.lang.String version
public java.lang.Class<FBaccess_FBcl> class_FBaccess_FBcl
public static final java.util.List<Din_FBcl> iterDinEmpty
public final java.util.Map<java.lang.String,java.lang.String> cmprOpReverse
public final java.util.Map<java.lang.String,java.lang.String> cmprOp
public final java.util.Map<java.lang.String,java.lang.String> numOp
public final java.util.Map<java.lang.String,java.lang.String> numOpFirst
public final java.util.Map<java.lang.String,java.lang.String> unaryOp
final java.lang.String sDbgFBexpr
final java.lang.String sDbgFBexprEvin
final Prj_FBCLrd prj
public boolean bVerboseCode
public java.lang.String sNewlineIndent
final java.util.TreeMap<java.lang.String,org.vishia.util.OutTextPreparer> idxOtx
#readTpl(Class, String)
.
The content comes from the script as argument pathTpl.final java.util.Map<java.lang.String,org.vishia.util.OutTextPreparer.DataTextPreparer> idxOtdata
final java.util.Map<java.lang.String,java.lang.Object> idxConstData
org.vishia.util.OutTextPreparer otxCallFB_evin
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otxCtorFB_evin
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otxCtorObjFB_evin
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otxInitFB_evin
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otxEvChainExprSetvar
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otxExprTerm
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otxExprAccessElement
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otx_setVar_FBexpr
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otx_defineLocalVar_FBexpr
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otx_evMdlOutStart
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otx_evMdlOutEnd
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otx_setMdlOutScalar
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otx_setMdlOutArrayCpy
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otx_setMdlOutArrayExpr
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otx_setMdlOutStructCpy
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otxAccessFBdout
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otx_setVarStruct
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otx_setVarArrayElem
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otx_setVarX_Array
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otx_setVarX_Elem
#prcEvChain(Evin_FBcl, Integer, Writer)
.org.vishia.util.OutTextPreparer otxExprEv_OFB_Variable
#prcEvchainOperation(Evout_FBcl, Module_FBcl, Appendable)
org.vishia.util.OutTextPreparer otxExprIf
#prcEvchainOperation(Evout_FBcl, Module_FBcl, Appendable)
org.vishia.util.OutTextPreparer XXXotx_exprSetCond
org.vishia.util.OutTextPreparer otx_exprCondIf
org.vishia.util.OutTextPreparer otxExprElse
org.vishia.util.OutTextPreparer otx_exprCondBitsIf
org.vishia.util.OutTextPreparer otxExprCondBitsEndif
org.vishia.util.OutTextPreparer otxExprEndif
#prcEvchainOperation(Evout_FBcl, Module_FBcl, Appendable)
java.lang.String testData
public WriterCodegen(Prj_FBCLrd prj)
public static java.lang.Iterable<java.lang.Integer> iterBits(long[] bitArray)
public void readTpl(java.lang.Class<?> classInJar, java.lang.String pathTpl, org.vishia.msgDispatch.LogMessage log)
idxOtx
with empty instances of otx.classInJar
- given then read from jar-File, null: read as filepathTpl
- relative path to classInJar or path in file systemjava.io.IOException
java.text.ParseException
public void parseScripts(org.vishia.msgDispatch.LogMessage log)
idxOtx
and set otxCallFB_evin
.java.text.ParseException
public void writeCode(java.io.File dirout, java.io.File dirCmp, java.lang.String sMdlName, Module_FBcl mdl, org.vishia.msgDispatch.LogMessage log)
fout
- output file path for the code.otxMain
- name of the main script (distinction header and C-Implementation etc.)argName
- name of the one argument for otxMainmdl
- internal Java data for code generation, the module.log
- for error logpublic void insertPoint(WriterCodegen.OtxWorkData wd, java.lang.StringBuilder OUT)
public void doInsert(WriterCodegen.OtxWorkData wd, java.lang.StringBuilder OUT)
public boolean checkSetLocalVariable(java.lang.String name, WriterCodegen.OtxWorkData wd)
org.vishia.util.OutTextPreparer.DataTextPreparer getCreateOtxData(org.vishia.util.OutTextPreparer otx, WriterCodegen.OtxWorkData wd)
OutTextPreparer.exec(Appendable, org.vishia.util.OutTextPreparer.DataTextPreparer)
running repeatedly in the same thread.
Hint: For more as one thread use different instances. Use the threadId also as key.otx
- public void genVariableDef(Module_FBcl mdl, WriterCodegen.OtxWorkData wd, java.lang.Appendable out) throws java.io.IOException
FBlock_FBcl.kind()
is == FBlock_FBcl.Blocktype#VarAfterExpr
and then calls the otx script with the type name of the FBlock_FBcl.typeName()
following by "_h".
<otx: VarZ_OFB_h ...
or <otx: VarV_OFB_h ...
or <otx: VarL_OFB_h ...
whereby 'VarL_OFB' is a local variable, should not create a variable definition here, but can be used as comment docu line.
mdl
- Module's dataout
- to write the source codejava.io.IOException
public void prcEvchainOperation(EvtreeNode_FBcl nodeRoot, Evout_FBcl evStartArg, Module_FBcl mdl, WriterCodegen.OtxWorkData wd, java.lang.Appendable out) throws java.io.IOException
EvtreeNode_FBcl
from evStart to generate the code for this event as operation.
This routine should be called inside the otx script for the implementation code.evStart
- The event which is the start event of the operation.mdl
- The module dataout
- Output. It is anytime a StringBuilder, needs insertion points.java.io.IOException
private void prcEvNode(Evout_FBcl evinMdl, EvtreeNode_FBcl evNode, long[] condBitsSrc, EvtreeNode_FBcl.IteratorEvoutTree iterTree, Module_FBcl mdl, WriterCodegen.OtxWorkData wd, java.lang.Appendable out, int recursion) throws java.io.IOException
EvtreeNode_FBcl
called in prcEvchainOperation(EvtreeNode_FBcl, Evout_FBcl, Module_FBcl, OtxWorkData, Appendable)
following the event node chain.
This follows the connection between two FBlocks or the module's evinMdl and evoutMdl.evinMdl
- The modules evin or the evin on start of this event chainevNode
- the TreeNode with the evin to the FBlockcondBitsSrc
- null or maybe given bits for conditions, which are checked with input data.iterTree
- The iterator where the evNode is gotten from. Used to continue on sibling etc. if conditions givenmdl
- The modulewd
- out
- recursion
- java.io.IOException
private void prcEvNodesBranch(Evout_FBcl evinMdl, EvtreeNode_FBcl evNode, Evout_FBcl evoutSrc, Evin_FBcl XXXevin, long[][] condBits, int ixCond, WriterCodegen.OtxWorkData wd, Module_FBcl mdl, java.lang.Appendable out, int recursion) throws java.io.IOException
java.io.IOException
private void prcEvinFBlock(Evout_FBcl evinMdl, Evout_FBcl evoutSrc, Evin_FBcl evinDst, long[] condBitsSrc, java.lang.String sVariant, WriterCodegen.OtxWorkData wd, Module_FBcl mdl, java.lang.Appendable out) throws java.io.IOException
#prcEvchainOperation(Evout_FBcl, Module_FBcl, OtxWorkData, StringBuilder)
for each event from the queue.
It calls one of the described processing in the given order of the following list:
FBlock_FBcl.typeName()
is existing.
Means, specific FBtype_FBcl
can have there own source code generation script.
The script is called with the arguments:
FBlock_FBcl
itself due to evin.fb
Din_FBcl
, the first din if given, or null if the fb has not an input. This helps on some simple FBlocks to access
Dout_FBcl
, the first output if given, or null if the fb has not an output. This helps on some simple FBlocks to access
DoutType_FBcl
, This helps on some simple FBlocks to access
Evin_FBcl
the evinDst as argument of this operation, it is the original given evin from the event queue
Evout_FBcl
the evSrc as argument of this operation, it is the source of the evin usable for comments in source code.
FBlock_FBcl.kind()
== FBlock_FBcl.Blocktype#VarAfterExpr
and the update pin is reached,
in that kind point above <otx: VarZ_OFB_upd...
is called for update source code.
with the arguments shown in the point before.
FBaccess_FBcl
then #prcEvinFBaccess(Evout_FBcl, Evin_FBcl, List, Map, Appendable)
is called,
see there.
Module_FBcl.idxFBlockTEST
, then normally no code generation should be done for it in this operation.
But on option -verbodeCode the <otx: infoFBtest ...
is called to get an info about this FBlock as part of the event queue.
PinKind_FBcl.isModulePin()
)
then <otx: evChainMdlOut...
is called with the arguments
Evin_FBcl.iterAssocDin()
all inputs to this event.
<otx: callFB_evin:...
is searched and should be found.
This found otx is called with the same arguments as <otx: evChainMdlOut...
, iterDin, evout and evin.
Module_FBcl.idxFBlockTEST
) evout are not considerate.
FBlock_FBcl.iterEvout(Evin_FBcl)
is called to get the correspond evout,
and they are put in the queue calling #addEventNextAll(List, Evin_FBcl, Appendable)
to generate the code for this FBlocks afterwards in the event order.
The event order is firstly regard immediately following events, later parallel events.
This is done by "last in first out" organization of the queue.
evoutSrc
- The source of this evin, only used for commentevinDst
- the evin to processqueueEvSrc
- queue to add following evout of the FBlock.idxEvStartChainCodegen
- Hash Map stores the already used events for codeGen to prevent twice or circular code generation,
may be caused only by an software errormdl
- The module's dataout
- output for source codejava.io.IOException
private void prcEvinFBaccess(Evout_FBcl evSrc, Evin_FBcl evinDst, long[] condBits, WriterCodegen.OtxWorkData wd, java.lang.Appendable wr) throws java.io.IOException
otx_setVarArrayElem
or otx_setVarStruct
or it does nothing because it is an AccessGet...OFB.
Last one is processed backward.
Anywhere the event is forwarded to all destinations.evSrc
- the evout before this FBlock, only for commentevinDst
- the relevant prep evin of the FBlockqueueEvSrc
- queue to add new driven eventsidxEvStartChainCodegen
- Hash Map stores the already used events for codeGen to prevent twice or circular code generation,
may be caused only by an software errorwr
- outputjava.io.IOException
private void prcEvinFBexpr(Evout_FBcl evSrc, Evin_FBcl evinDst, long[] condBits, WriterCodegen.OtxWorkData wd, java.lang.Appendable wr) throws java.io.IOException
FBexpr_FBcl.cAccess
which is also the first character in din[0]
able to see in IEC61499 presentation as constant initializer of 'expr'
<otx: setVar_FBexpr...
.
Evout_FBcl
only for comment
Evin_FBcl
of the FBexpr
FBexpr_FBcl
the FBexpr itself
FBexpr_FBcl.getOperation()
PinKind_FBcl.Dout
FBlock_FBcl
the FBlock of the variable after the dout which is type of DoutExpr_FBcl
.
It is null if the expression has not a connection on its DoutExpr_FBcl
.
Note: All other outputs of the expression are only Dout_FBcl
.
DoutExpr_FBcl
genExprTerm(StringBuilder, String, FBexpr_FBcl, long[], String, int, String, OtxWorkData, int)
maybe with the correct component on complex or comprehensive types.evSrc
- the evout before this FBlock, only for commentevinDst
- the relevant prep evin of the FBlockqueueEvSrc
- queue to add new driven eventsidxEvStartChainCodegen
- Hash Map stores the already used events for codeGen to prevent twice or circular code generation,
may be caused only by an software errorwr
- outputjava.io.IOException
private void prc_setVar_FBexpr(FBexpr_FBcl fbx, Evout_FBcl evSrc, Evin_FBcl evinDst, Dout_FBcl doutExpr, Dinout_FBcl varExpr, java.util.List<Dout_FBcl> listVarOut, long[] condBits, WriterCodegen.OtxWorkData wd, java.lang.Appendable out) throws java.io.IOException
otx_defineLocalVar_FBexpr
, otx_setVar_FBexpr
.
This is an expression marked with FBexpr_FBcl.cAccess
== one of "&=".
The proper expression is detect in EvoutTreePrc_FBcl
.fbx
- evSrc
- evinDst
- doutExpr
- The output of the expression itself, it is usual avarExpr
- The variable after the expression. It can be either a module's output, which is an Din_FBcl,
an referenced input of a FbLock,
or also the variable after expression given as Dout_FBcl.listVarOut
- a list of variable which are used in the expression and which should be defined as stack local variable.condBits
- to access inputs, the condition from the evSrcwd
- out
- java.io.IOException
private void callFBoper(FBexpr_FBcl fbx, long[] condBits, Dout_FBcl dout, WriterCodegen.OtxWorkData wd, java.lang.Appendable wr) throws java.io.IOException
FBexpr_FBcl.getFunction()
.
Dout_FBcl
of the expression.
Note: Intrinsically this operation should be hold in the EvinType_FBcl
pin
but this is not possible because the expression is not determined by the type.
Or think about, a special type is created for a specific expression since 2024-07-26 also because different data types.
FBlock_FBcl.reference
pin, then it is the reference to the associated FBlock
where this operation is a member of. Hence the operation of the type is called, with the reference as this pointer.
fbx
- The FBoperdout
- presents the value of the expression, all other outputs are call by value arguments.wr
- to write the code.java.io.IOException
public java.lang.String genValueDin(Din_FBcl din, long[] condBits, java.lang.String ref, java.lang.String cacc, WriterCodegen.OtxWorkData wd)
<:set:dinVar=genValueDin(fbx.din[1],'', 0)>
This example shows set a access variable string with generated access code to use it to set the components of the variable.
Also it is called inside #prepareExprTextGiven(Appendable, FBexpr_FBcl, String)
to replace the X1.. variables with the code on inputs.
Hence the content is not immediately written for the code generation, instead it is prepared in a StringBuilder
and returned as String to use.
It calls #genValueDout(Dout_FBcl, String, Appendable, int)
with this StringBuilder if the input has a connection to an output.
Non connected input constant values are immediately returned.
din
- The data input which is connected to any output or it has a Din_FBcl.sConstant
cacc
- access to an element of an input variable, for example ".re" or "[1]"ref
- reference to the module data, it is often "thiz" inside the module, or a specific reference variablepublic java.lang.String genDinAccess(Din_FBcl din, PinConnect_FBcl conn, long[] condBits, java.lang.String sVariant, java.lang.String ref, int ix, java.lang.String cacc, WriterCodegen.OtxWorkData wd, java.lang.StringBuilder out)
DinExpr_FBcl
, this is an input of an FBexpr_FBcl
,
then #genExprIn(DinExpr_FBcl, FBexpr_FBcl, String, String, Appendable, int)
is called.
This regards also the K.. input of an expression.
Dout_FBcl
as source for the input.
If yes, It is also a type cast and an access to a struct or array element can be contained in the input string.
This is regarded here.
Then with the doutSrc #genValueDout(Dout_FBcl, String, String, Appendable, int)
is called.
Din_FBcl.getConstant()
then this constant value is used for the generated code for this input.
TODO with the type of the din maybe a translation of the constant may be proper for example to create "3.14f"
as float designation for C programming if "3.14" is given, or supplement with "" for a String input.
#genValueDout(Dout_FBcl, String, int)
from the connected source or taks the Din_FBcl.sConstant
din
- The data input which is delivered from any output or it has a Din_FBcl.sConstant
conn
- null or the specific connection from din. Then conn: PinConnect_FBcl.pinDst
should == din.ref
- reference to the module data for the source of din, it is often "thiz" inside the module, or a specific reference variablecacc
- access to an element of an input variable, for example ".re" or "[1]"out
- the buffer to write the generated source codepublic void genDinAccessConn(Din_FBcl din, PinConnect_FBcl connSrc, java.lang.String cacc, long[] condBits, java.lang.String ref, WriterCodegen.OtxWorkData wd, java.lang.StringBuilder out) throws java.io.IOException
Din_FBcl
for a given connection PinConnect_FBcl
din
- It is the same as connSrc: PinConnect_FBcl.pinDst
connSrc
- the given connection between dout and dindtin
- data type of din, same as din: Dinout_FBcl.dType()
cacc
- access string to thecondBits
- the condition bits necessary for backward selection of dout for inline expressionsref
- wd
- Write dataout
- The output where to write the code.java.io.IOException
public java.lang.String genRefIn(PinRef_FBcl din, long[] condBits, java.lang.String ref, java.lang.String cacc, WriterCodegen.OtxWorkData wd, java.lang.StringBuilder out, int recursion)
#genValueDout(Dout_FBcl, String, int)
from the connected source,
that is a PinPort_FBcl
returnd by PinRef_FBcl.getConnPort()
or takes the Din_FBcl.sConstant
din
- The data input which is delivered from any output or it has a Din_FBcl.sConstant
cacc
- access to an element of an input variable, for example ".re" or "[1]"ref
- reference to the module data, it is often "thiz" inside the module, or a specific reference variablerecursion
- public void genValueDout(Dout_FBcl dout, long[] condBits, java.lang.String ref, java.lang.String cacc, WriterCodegen.OtxWorkData wd, java.lang.StringBuilder sb, int recursion) throws java.io.IOException
FBlock_FBcl
, also an FBexpr_FBcl
or a Variable after expression.
It is called from genDinAccess(Din_FBcl, PinConnect_FBcl, long[], String, String, int, String, OtxWorkData, StringBuilder)
for the backward connected output.
VarL_OFB_acc
etc.
to access the output of variables as output of an expression.
DoutExpr_FBcl
,
then #genExprOut(Dout_FBcl, FBexpr_FBcl, String, String, HashMap, Appendable, int)
is called
which regards all possibilies of expressions in the graphic.
<otx: doutAccessThis ...
is called, else <otx: doutAccessThis ...
,
with the following arguments:
FBlock_FBcl
from dout.fb
FBlock_FBcl.typeName()
dout
- The data output which delivers a valuesb
- StringBuilder to write inref
- reference to the module data, it is often "thiz" inside the module, or a specific reference variablecacc
- access to an element of an input variable, for example ".re" or "[1]"recursion
- java.io.IOException
private void genAccessGet(Dout_FBcl doutAccess, long[] condBits, FBaccess_FBcl fba, java.lang.String ref, java.lang.String cacc, WriterCodegen.OtxWorkData wd, java.lang.StringBuilder sb, int recursion) throws java.io.IOException
FBexpr_FBcl.getOperation()
or FBexpr_FBcl.cOp
what is done:
#prepareExprTextGiven(Appendable, FBexpr_FBcl, String, String)
.
DoutExpr_FBcl
(from the ofpExprOut pin style in odg diagram).
In this case param doutExpr may be null if the ofpExprOut is not connected.
This is detected by a before called #setVar_FBexpr(FBexpr_FBcl, Evout_FBcl, Evin_FBcl, Evout_FBcl, Appendable)
to define expression output variables.
In this case either for the given FBexpr_FBcl.getFunction()
a specific otx script is found, then it is executed with the arguments:
String
, the name in FBexpr_FBcl.getOperation()
till the opened '('.
FBexpr_FBcl
the expression
#callFBoper(FBexpr_FBcl, Dout_FBcl, Appendable)
is executed.
genExprTerm(StringBuilder, String, FBexpr_FBcl, long[], String, int, String, OtxWorkData, int)
.
The doutExpr should be given, not null.
doutExpr
- It is the dout connected to either any input or to the variable which presents this output in the graphic.
It can be null if one of the FBlock_FBcl.dout
is type of DoutExpr_FBcl
but has no connection,
or it is null if all FBlock_FBcl.dout
has variables on its outputs,
hence the type of FBlock_FBcl.dout
is only Dout_FBcl
, and not DoutExpr_FBcl
.
This is detected by the before called #setVar_FBexpr(FBexpr_FBcl, Evout_FBcl, Evin_FBcl, Evout_FBcl, Appendable)
fbx
- The expressionref
- reference to the module data, it is often "thiz" inside the module, or a specific reference variablecacc
- optional an access string added to any data inputsb
- output buffer.java.io.IOException
public void genVarExpr(Dout_FBcl doutVar, Dout_FBcl doutExpr, FBlock_FBcl fb, long[] condBits, java.lang.String ref, int ix, java.lang.String cacc, WriterCodegen.OtxWorkData wd, java.lang.StringBuilder sb) throws java.io.IOException
doutExpr
- fb
- condBits
- ref
- ix
- cacc
- wd
- sb
- recursion
- java.io.IOException
public void genVarAccessSet(Dout_FBcl doutVar, Dout_FBcl doutExpr, FBaccess_FBcl fba, long[] condBits, java.lang.String varAcc, WriterCodegen.OtxWorkData wd, java.lang.CharSequence nli, java.lang.StringBuilder sb) throws java.io.IOException
java.io.IOException
private void genExprOut(Dout_FBcl doutExpr, java.lang.String selDinElemDst, FBexpr_FBcl fbx, long[] condBits, java.lang.String ref, int ix, java.lang.String cacc, WriterCodegen.OtxWorkData wd, java.lang.StringBuilder sb, int recursion) throws java.io.IOException
FBexpr_FBcl.getOperation()
or FBexpr_FBcl.cOp
what is done:
#prepareExprTextGiven(Appendable, FBexpr_FBcl, String, String)
.
DoutExpr_FBcl
(from the ofpExprOut pin style in odg diagram).
In this case param doutExpr may be null if the ofpExprOut is not connected.
This is detected by a before called #setVar_FBexpr(FBexpr_FBcl, Evout_FBcl, Evin_FBcl, Evout_FBcl, Appendable)
to define expression output variables.
In this case either for the given FBexpr_FBcl.getFunction()
a specific otx script is found, then it is executed with the arguments:
String
, the name in FBexpr_FBcl.getOperation()
till the opened '('.
FBexpr_FBcl
the expression
#callFBoper(FBexpr_FBcl, Dout_FBcl, Appendable)
is executed.
genExprTerm(StringBuilder, String, FBexpr_FBcl, long[], String, int, String, OtxWorkData, int)
.
The doutExpr should be given, not null.
doutExpr
- It is the dout connected to either any input or to the variable which presents this output in the graphic.
It can be null if one of the FBlock_FBcl.dout
is type of DoutExpr_FBcl
but has no connection,
or it is null if all FBlock_FBcl.dout
has variables on its outputs,
hence the type of FBlock_FBcl.dout
is only Dout_FBcl
, and not DoutExpr_FBcl
.
This is detected by the before called #setVar_FBexpr(FBexpr_FBcl, Evout_FBcl, Evin_FBcl, Evout_FBcl, Appendable)
selDinElemDst
- to select DinExpr due to PinConnect_FBcl#elemDst
ix
- if >=0 then doutExpr is an array,fbx
- The expressionref
- reference to the module data, it is often "thiz" inside the module, or a specific reference variablecacc
- optional an access string added to any data inputsb
- output buffer.java.io.IOException
private void genExprTerm(java.lang.StringBuilder sb, java.lang.String selDinElemDst, FBexpr_FBcl fbx, long[] condBits, java.lang.String ref, int ix, java.lang.String cacc, WriterCodegen.OtxWorkData wd, int recursion) throws java.io.IOException
sb
- the output, usual a StringBuilderfbx
- the FBexpr itselfref
- reference to the module data, it is often "thiz" inside the module, or a specific reference variablecacc
- additional access String to access each the same sub element (".re", ".im", "[ix]")recursion
- java.io.IOException
private java.lang.String translateOperatorToTargetLang(char dType, java.lang.String sGraphicOperator, java.util.Map<java.lang.String,java.lang.String> idxTrl, java.lang.String sDefault)
dType
- The data type chactersGraphicOperator
- given operator in graphicidxTrl
- translator map. key may be dType + sGraphicOperator or only sGraphicOperatorprivate void genExprTermCmpr(java.lang.StringBuilder sb, java.lang.String selDinElemDst, FBexpr_FBcl fbx, java.lang.Iterable<DinExpr_FBcl> dinValues, long[] condBits, java.lang.String ref, int ix, java.lang.String cacc, WriterCodegen.OtxWorkData wd, int recursion) throws java.io.IOException
java.io.IOException
private void genExprIn(DinExpr_FBcl din, FBexpr_FBcl fbx, long[] condBits, java.lang.String sOperatorLeftArg, java.lang.String sOperator, java.lang.String sUnaryOp, java.lang.String ref, int ix, java.lang.String caccArg, WriterCodegen.OtxWorkData wd, java.lang.StringBuilder sb, int recursion) throws java.io.IOException
din
- One of the expression inputfbx
- of this FBexprref
- reference to the module data, it is often "thiz" inside the module, or a specific reference variableix
- -1 or >=0 if the expression is used as array expression.cacc
- possible access to component of variablessb
- outputrecursion
- java.io.IOException
private void prepareExprTextGiven(java.lang.StringBuilder out, FBexpr_FBcl fbx, long[] condBits, java.lang.String ref, java.lang.String sFn, WriterCodegen.OtxWorkData wd) throws java.io.IOException
#genValueDin(Din_FBcl, String)
is called
which may invoke (depending on the input delivering FBlock) a proper otx Script.fbx
- The FBexpr using its FBlock_FBcl.din
ref
- reference to the module data, it is often "thiz" inside the module, or a specific reference variablesFn
- the given function from FBexpr_FBcl.sFn
java.io.IOException
private boolean testCondition(Din_FBcl din, long[] condBits)
testCondition(Dout_FBcl, long[])
for all sources.din
- may have connections or notcondBits
- maybe nullprivate boolean testCondition(Dout_FBcl doutSrc, long[] condBits)
Evinout_FBcl.condBits
.
Calls Evinout_FBcl.getConditionBits()
to check
and calls Bitfield.checkOrConditionMet(long[][], long[])
to test the condition.doutSrc
- the dout where the condition should met.condBits
- maybe null