Beckhoff-USA-Community / SPT-Libraries

MIT License
70 stars 16 forks source link

Cyclic Logic #7

Closed albertgoodwin closed 1 year ago

albertgoodwin commented 1 year ago

Hi. I really like this project, and would like to implement a simplified version of it in our own library, as we build standalone machines that don't need a lot of this functionality.

I'm wondering what the reason is for having a cyclic logic method in every function block. It seems like a lot of overhead, and a lot of overridden methods, when each function block could just be called cyclically. Could you explain this?

MarkLewis-Beckhoff commented 1 year ago

Hi Albert, The cyclic logic method is built into our base interface as the place where all of the cyclic code is run. it is for all intents and purposes the only method which automatically is called every cycle.

we did this because for most people living in the OOP world the code must be called to run. As such we made the choice to not have any code in the body of a function block as this would break the OOP design pattern.

if you were to choose to not use it you would need to use the body of the function block and none of the under the hood calls will work automatically any longer.

essentially every module has code that has to be called every cycle and this is where it lives.