I have a function block A
that has one variable output
(defined in the FUNCTION_BLOCK A
method) and this FB_init
method:
METHOD FB_init : BOOL
VAR_INPUT
bInitRetains : BOOL; // if TRUE, the retain variables are initialized (warm start / cold start)
bInCopyCode : BOOL; // if TRUE, the instance afterwards gets moved into the copy code (online change)
END_VAR
VAR_OUTPUT
output : REAL := 0;
END_VAR
THIS^.output := output;
When I call this constructor as follows:
a : A(output => outputLocal);
Identifier 'output' not defined
. But I did defined
this parameter in the constructor method.No matching FB_init method found for instantiation of A
localoutput
to the variable output
(of the FB A
) in the FB constructor.By declaring output in the VAR_OUTPUT
section of the method, you are making it a local output variable to the method, not an input variable.
You need to declare a VAR_OUTPUT
in the FunctionBlock
and a VAR_INPUT
in the constructor and assign the input variable from the constructor to the output variable of the FunctionBlock
—probably by REF=
, or you'll just get the value.