Simple Codesys OOP - Inheritance
ฝัง
- เผยแพร่เมื่อ 16 ต.ค. 2024
- In Codesys, Object Oriented Programing (OOP) is implemented through Function Blocks.
A critical part of OOP is Inheritance, and this is done by "extending" the function block.
TLDW:
1. The derived class 'Son' inherit all variables and methods from the base class "Father'
2. You may add extra methods to the Son and also overwrite methods inherited from the Father
3. After overwriting the inherited methods, you can still use the method from Father using the SUPER pointer
4. Use OOP when you have many similar kind of sensors or actuators. (Like a motor class can split into Pumps, HVAC, grinders...) Fixing bugs in the base class will fix the same problem in all the classes that inherit from it. Reduce need to copy and paste
Sorry for long video
Maybe I should do one video on interfaces next time. :)
Very nicely presented. Interesting first part, well chosen examples. The second part, with the pumps, a little unconvincing :-)
Thanks for the feedback. On hindsight, the video should have built towards an example with the pump. Will keep in mind for future video
Great example! Easy to understand and conveyed the points clearly, thank you
so good for expanding OOP
Cool
Thank you.
We are lot of subscribers 😊😂❤
Sir ,can you give me the backup?
Thanks🙏