Cross reference

From Axel Public Wiki
Jump to navigation Jump to search

FOREWORD

The cross-reference functions allows to identify and list all the usages (references) of the symbols (vaiables, POUs, type definitions etc.) of a PLC application. For each symbol all its references inside the application are listed, for each reference the following elements are reported:

  • referencing block (POU or variable group)
  • position inside the block (e.g. the line inside the source code)
  • access type, read or write

Availability

The cross-reference is available on LogicLab releases starting from 4.0.x.

GENERAL INFORMATION

Cross reference generation

The cross reference is generated during the compilation of the code. The generation of the cross reference should be enabled by checking "Project" + "Options" + "Build output" + "Generate cross reference"

Enabling cross-reference generation

Cross reference options

The cross-reference generation process is subject to several options.

These options allows to select which elements are to be reported in the output file (CRF)

Bit n° Symbolic name Description
0 CRF_BTRACEGLOBALVARS Report references to global variables
1 CRF_BTRACELOCALVARS Report references to POU's local variables
2 CRF_BTRACEPROGS Report references to programs (from tasks)
3 CRF_BTRACEFBLKS Report references to function blocks
4 CRF_BTRACEFUNCTS Report references to functions
5 CRF_BTRACEEMBEDDEDFUNCTS Report references to embedded functions (implemented in the target system)
6 CRF_BTRACETASKS Report references to tasks
7 CRF_BTRACEMACROS Report references to macros
8 CRF_BTRACESTRUCTS Report references to structures
9 CRF_BTRACEENUMS Report references to enumeratives
10 CRF_BTRACESUBRS Report references to subranges
11 CRF_BTRACETYPEDEFS Report references to type definitions
24 CRF_BTRACE_IN_PROGS Scan programs code for references to objects
25 CRF_BTRACE_IN_FBLKS Scan function blocks code for references to objects
26 CRF_BTRACE_IN_FUNCTS Scan functions code for references to objects

The bit position reported in the above table refers to the corresponding bit mask saved into the PLCRJ LogicLab project file. The same value can be used as parameters for cross reference generation performed by means of the LogicLab OLE interface.

Cross reference output

The cross reference output is a standard XML format file having .CRF file extension:

<logiclabprojectname>.CRF

The structure and the data contained in the CRF file is explained in the following paragraph.

CROSS REFERENCE FILE FORMAT

The complete file structure with the 1st level tags is shown below:

 <?xml version="1.0" encoding="UTF-16" standalone="no"?>
 <crossReference sourceID="..." module="..." optionsMask="...">
     <tasks>
         <!-- ...list of tasks... -->
         <task> .. </task>
     </tasks>
     <programs>
         <!-- ...list of programs... -->
         <program> .. </program>
     </programs>
     <functions>
         <!-- ...list of functions... -->
         <function> .. </function>
     <functions/>
     <functionBlocks>
         <!-- ...list of function blocks... -->
         <functionBlock> .. </functionBlock>
     </functionBlocks>
     <vars>
         <!-- ...list of global variables... -->
         <var> .. </var>
     </vars>
     <macros>
         <!-- ...list of macros... -->
         <macro> .. </macro>
     </macros>
     <structs>
         <!-- ...list of structs... -->
         <struct> .. </struct>
     </structs>
     <enums>
         <!-- ...list of structs... -->
         <enum> .. </enum>
     </enums>
     <subranges>
         <!-- ...list of subranges... -->
         <subrange> .. </subrange>
     </subranges>
     <typedefs>
         <!-- ...list of typedefs... -->
         <typedef> .. </typedef>
     </typedefs>
     <unknownObjs>
         <!-- here are listed references to
              objects that are not part of the module
              List filled only in case of internal errors -->
     </unknownObjs>
 </crossReference>

The following rules apply to the cross-reference file:

  • Each 1st level tag (i.e. programs, functions etc.) is part of the CRF file when the respective cross-reference option is active (See Cross reference options).
  • Inside each 1st are listed all the object of the relative type (i.e. variables, programs, etc.)
  • Inside each tag representing an object, all references to the object (if any) are listed

Cross reference sample

 <?xml version="1.0" encoding="UTF-16" standalone="no"?>
 <crossReference sourceID="0x2680E6E5" module="SampleApp" optionsMask="0x3000001D">
     <vars>
         <var name="SYSTIMER" source="TGT" sid="V:TGT:SYSTIMER">
	    <ref op="RD" pos="FB::PIDBLOCK#4"/>
            <ref op="RD" pos="FB::PIDBLOCK#6"/>
            <ref op="RD" pos="P::MAIN#17"/>
         </var>
         <var name="PRESSURE" sid="V::PRESSURE">
            <ref op="WR" pos="P::MAIN#8"/>
            <ref op="RD" pos="FB::CALC^4$23"/>
         </var>
     </vars>
 </crossReference>

In the sample above:

  • the name of the PLC project is SampleApp
  • the options mask active at cross-reference generation time is 0x3000001D
  • the variable SYSTIMER has 3 references (usages) in the application
  1. read access at line 4 of function block PIDBLOCK
  2. read access at line 6 of function block PIDBLOCK
  3. read access at line 14 of program MAIN
  • the variable PRESSURE has 2 references (usages) in the application
  1. write access at line 8 of program MAIN
  2. read access at network 4, block 23 of function block CALC

Tags description


TAG crossReference

Root tag, identifies the LogicLab's cross reference output. Attributes:

Attribute Description
module Name of the PLC module (application)
sourceID 32-bit checksum of the correponding module source code
optionsMask 32-bit mask reporting the cross-reference options active

TAG tasks, programs, functions, functionBlocks, vars, macros, structs, enums, subranges, typedefs

These tags have no attributes and they contain the list of the respective objects in the module.


TAG task, program, function, functionBlock, macro, struct, enum, subrange, typedef

Each of these tags refer to a specific object type. All these tags have the same set of attributes:

Attribute Description
module Name of the PLC module (application)
name Object name
source Source module, if present indcates the library source name or TGT for objects defined in the target definition file (.tgt)
sid Source identifier, string with unique reference to the object (see Object SID description)

TAG var

The tag var has the following attributes:

Attribute Description
module Name of the PLC module (application)
name Object name
source Source module, if present indcates the library source name or TGT for objects defined in the target definition file (.tgt)
class Class of the variable (for function and function blocks, can be: in, out, inout, ext);
sid Source identifier, string with unique reference to the object (see Object SID descriptor)

TAG ref

The tag ref indicates a reference (code access, declaration etc.) to the object of the containing tag.

Attribute Description
module Name of the PLC module (application)
op Operation executed on the object, can be RD (read operation) or WR (write operation)
pos Position of the reference to the object (see Position string descriptor)

String descriptors

Two different string descriptors are used in the CRF file:

  • PLC object descriptor (SID)
  • code position descriptor

PLC object descriptor (SID)

Univocally identifies a PLC object. It has the following form:

<object type ID>:[<source module>]:[<POU name>.]<object name>

where:

object type ID Token that identifies the object type, can be:
T Task
P Program
F Function
FB Function block
V Variable
M Macro
STRU Structure
EN Enumerative
SUBR Subrange
TD Typedef
source module Module of the PLC application where the object is defined. Can be:
  • a library name
  • TGT that means target definition file
  • empty that means application body
POU name Name of the POU in which the object is defined
object name Name, identifier of object

PLC object descriptor samples

V:TGT:SYSANALOGINPUTS → Variable SYSANALOGINPUTS in target definition file
FB:STANDARD:CTD_UDINT → Function block CTD_UDINT in library STANDARD
V::CALCULUS.ALFA → Variable ALFA of function CALCULUS in main application module


Code position descriptor

Identifies a position in the source code of the PLC application. It has the following form:

<object type ID>:[<source module>]:<POU name><code position>

where:

object type ID Token that identifies the object type, see PLC object descriptor
source module Module of the PLC application where the object is defined see PLC object descriptor
POU name Name of the POU in which the object is referenced
code position The position (line or graphic block) inside the POU of the reference to the object. Can be:
  • #<number> line number inside a textual source code
  • ^<blockID> position inside a graphic source code

Code position descriptor samples

FB:STANDARD:TOF#23 → Function block TOF in library STANDARD, code line 23
P::LDLOGIC^1$4 → Program LDLOGIC in the application body, graphic block ID 1$4

CROSS-REFERENCE OLE INTERFACE FUNCTIONS

description to be added