Reputation: 65
I would like to extend a FB but i need to call the code of the basis FB.
example Code
FB_Basis
FUNCTION_BLOCK FB_Basis
VAR_INPUT
bInTest : BOOL;
END_VAR
VAR_OUTPUT
nOutTest : INT;
END_VAR
IF bInTest THEN
nOutTest := nOutTest + 1;
END_IF
FB_Test
FUNCTION_BLOCK FB_Test EXTENDS FB_Basis
VAR_INPUT
bInTest2 : BOOL;
END_VAR
VAR_OUTPUT
nOutTest2 : INT;
END_VAR
IF bInTest2 THEN
nOutTest2 := nOutTest2 + 1;
END_IF
The Call:
FB_Test( bInTest:=
, nOutTest=>
, bInTest2:=
, nOutTest2=>
);
If I set bInTest at TRUE I want the Output nOutTest count up but it doesn't.
I can't find information how to handle code from the FB_basis in the InfoSys from Beckhoff the just explain the behavior of methods.
I don't know how to call the code, would be thankful for answers.
Upvotes: 2
Views: 594
Reputation: 2979
You can use SUPER^()
to call the body of the parent function block. You need to add this to the body of FB_Test
:
FUNCTION_BLOCK FB_Test EXTENDS FB_Basis
VAR_INPUT
bInTest2 : BOOL;
END_VAR
VAR_OUTPUT
nOutTest2 : INT;
END_VAR
SUPER^(); // Call the body of FB_Basis
IF bInTest2 THEN
nOutTest2 := nOutTest2 + 1;
END_IF
Upvotes: 3