Metric: Number Of Instances

User Description

The Number Of Instances metric is used to get information about how often a complex type (function block, enumeration, structure, and so on) is used as variable type on programming objects (programs, function blocks, and so on).

Metric Calculation

Inside the declaration part, you can define variables. Each variable has an associated data type (complex type or elementary type). When used, the instance count of this data type is increased by +1.

NOTE: If the variable data type is an array data type, the underlaying base data type is used and the instance count is handled as +1. The array length is not considered.
NOTE: Instantiation paths through different complex types are not considered. For example, if a function block is instantiated multiple times, the complex types inside are only counted once.

Example

Number Of Instances calculation example:

SR_Main
VAR
    fbMyAlphaModule: FB_MyAlphaModule;
END_VAR

FB_MyAlphaModule
VAR
   astAxisStructures: ARRAY [1..10] OF ST_MyAxisStructure;
   fbSubModule: FB_MySubModule;
END_VAR

FB_MySubModule
VAR
    fbAxis: FB_MyAxis;
END_VAR

ST_MyAxisStructure
VAR
   iID: INT;
   fbAxis: FB_MyAxis;
END_VAR

FB_MyAxis
VAR
END_VAR

Number Of Instances Results

Number Of Instances (FB_MyAlphaModule) = 1
Number Of Instances (FB_MySubModule) = 1
Number Of Instances (ST_MyAxisStructure) = 1
Number Of Instances (FB_MyAxis) = 2