Hello,
It seems to me like at the point when „[Initialization] public void __Init()“ function runs, C# is still not aware of the values that I have given in PLCnE of the INPUT variables that I have declared in my C# code. Is this true?
Thanks in advance.
Yes, that’s true, and that makes sense. The sequence of operations after the system has started up, every time the function (or function block instance) is executed in a Task, is:
1. Copy the values of all input parameters to the function (or function block instance) from the calling POU.
2. Process.
3. Copy the values of all output parameters from the function (or function block instance) back to the calling POU.
Before that sequence starts, the function (or function block instance) object must be created and initialised as part of the construction of the entire task. The values of input parameters are not considered as part of that process. In fact that wouldn’t be possible, unless the input parameters are hard-coded. For example - what if an input parameter is the result of a calculation? That calculation cannot be done before the task is executed for the first time, and the task cannot be executed until all the objects (including function block instances) are constructed and initialised.