Anwendungsfälle von geerbten Elementen

Generell können geerbte Elemente, auf die die Unterklasse entsprechenden Zugriff besitzt (siehe Abschnitt „Zugriffsmöglichkeiten auf geerbte Elemente“), auf drei verschiedene Arten genutzt werden:

Diese drei Anwendungsfälle werden im Folgenden am Beispiel des Elements "Methode" erläutert.

Unveränderte Nutzung

Funktionsbaustein FB_Base:

FUNCTION_BLOCK FB_Base
VAR
    fbAxis  : FB_Axis;
END_VAR

Methode FB_Base.ExecuteProcess:

METHOD ExecuteProcess : BOOL
VAR_INPUT
    bExecuteProcess  : BOOL;
END_VAR
// Calling axis module by passing input parameter "bExecuteProcess" of this method to the input parameter "bExecute" of method "Execute"
fbAxis.Execute(bExecute := bExecuteProcess);
 
// Setting the return value of this method as inverted error signal of the axis module
ExecuteProcess := NOT fbAxis.Error;

Funktionsbausteinstein FB_Sub:

FUNCTION_BLOCK FB_Sub EXTENDS FB_Base
VAR
END_VAR

Methode FB_Sub.ExecuteProcess:

[existiert nicht]

Überschreibung

Funktionsbaustein FB_Base:

FUNCTION_BLOCK FB_Base
VAR
    fbAxis  : FB_Axis;
END_VAR

Methode FB_Base.ExecuteProcess:

METHOD ExecuteProcess : BOOL
VAR_INPUT
    bExecuteProcess  : BOOL;
END_VAR
// Calling axis module by passing input parameter "bExecuteProcess" of this method to the input parameter "bExecute" of method "Execute"
fbAxis.Execute(bExecute := bExecuteProcess);
 
// Setting the return value of this method as inverted error signal of the axis module
ExecuteProcess := NOT fbAxis.Error;

Funktionsbausteinstein FB_Sub:

FUNCTION_BLOCK FB_Sub EXTENDS FB_Base
VAR
    fbCylinder  : FB_Cylinder;
END_VAR

Methode FB_Sub.ExecuteProcess:

METHOD ExecuteProcess : BOOL
VAR_INPUT
    bExecuteProcess  : BOOL;
END_VAR
// Calling cylinder module by passing input parameter "bExecuteProcess" of this method to the input parameter "bExecute" of method "Execute"
fbCylinder.Execute(bExecute := bExecuteProcess);
 
// Setting the return value of this method as inverted error signal of the cylinder module
ExecuteProcess := NOT fbCylinder.Error;

Erweiterung

Funktionsbaustein FB_Base:

FUNCTION_BLOCK FB_Base
VAR
    fbAxis  : FB_Axis;
END_VAR

Methode FB_Base.ExecuteProcess:

METHOD ExecuteProcess : BOOL
VAR_INPUT
    bExecuteProcess  : BOOL;
END_VAR
// Calling axis module by passing input parameter "bExecuteProcess" of this method to the input parameter "bExecute" of method "Execute"
fbAxis.Execute(bExecute := bExecuteProcess);
 
// Setting the return value of this method as inverted error signal of the axis module
ExecuteProcess := NOT fbAxis.Error;

Funktionsbausteinstein FB_Sub:

FUNCTION_BLOCK FB_Sub EXTENDS FB_Base
VAR
    fbCylinder  : FB_Cylinder;
END_VAR

Methode FB_Sub.ExecuteProcess:

METHOD ExecuteProcess : BOOL
VAR_INPUT
    bExecuteProcess    : BOOL;
END_VAR
// Extension: Calling cylinder module by passing input parameter "bExecuteProcess" of this method to the input parameter "bExecute" of method "Execute"
fbCylinder.Execute(bExecute := bExecuteProcess);
 
// Setting the return value of this method as inverted error signal of the cylinder module PLUS calling the base method and analyzing its return value
ExecuteProcess := NOT fbCylinder.Error AND SUPER^.ExecuteProcess(bExecuteProcess := bExecuteProcess);