Infosys在阅读器中打开 / AI 翻译

PLC · 0 次阅读

Use cases for inherited elements

In general, inherited elements to which the subclass has appropriate access (see section "Access options to inherited elements") can be used in three different ways:

These three use cases are explained below using the example of the "Method" element.

Unchanged use

Function block FB_Base:

FUNCTION_BLOCK FB_Base
VAR
    fbAxis  : FB_Axis;
END_VAR

Method 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;

Function block FB_Sub:

FUNCTION_BLOCK FB_Sub EXTENDS FB_Base
VAR
END_VAR

Method FB_Sub.ExecuteProcess:

[does not exist]

Overwrite

Function block FB_Base:

FUNCTION_BLOCK FB_Base
VAR
    fbAxis  : FB_Axis;
END_VAR

Method 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;

Function block FB_Sub:

FUNCTION_BLOCK FB_Sub EXTENDS FB_Base
VAR
    fbCylinder  : FB_Cylinder;
END_VAR

Method 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;

Extension

Function block FB_Base:

FUNCTION_BLOCK FB_Base
VAR
    fbAxis  : FB_Axis;
END_VAR

Method 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;

Function block FB_Sub:

FUNCTION_BLOCK FB_Sub EXTENDS FB_Base
VAR
    fbCylinder  : FB_Cylinder;
END_VAR

Method 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);