Skip to content

#980 PLCgen: fix event functions and their calls.

  • Best to review per commit.
  • Fixed PLCgen event functions and their calls:
    • Event functions now have an input parameter, not an in/out parameter.
    • Return values of event function calls are assigned to isProgress var.

I considered several alternatives:

  • Use both an in/out parameter and return type, as we have now. It would mean assigning the output of the function call to a variable (this fixes it, as reported in #980 (closed)). Then via the in/out parameter the value is written, and again it is overwritten when the return value is assigned (not sure of the order of these two). This would work, but probably be a bit confusing.
  • Use only the in/out parameter. But, functions must have a return type (I think?), and a dummy return value seems worse than what we have now.
  • Turn it into a function block with an in/out parameter only. These don't need to have a return type, I think. Not really sure how that would work in our setup. So far, we have only done timers.
  • Use an input parameter and return type. I don't think we need a local variable, since it seems we can just assign new values to the input variable and then return it at the end of the function. At least, that is what I read here: https://support.industry.siemens.com/cs/mdm/109011420?c=64960008715&lc=en-US.

I opted for the latter. It seems the simplest solution to program, and it leads to the simplest and easiest to read code, I think.

Closes #980 (closed)

Merge request reports