Documente Academic
Documente Profesional
Documente Cultură
2/2007
Automation Technology
in Practice
International
November
Reprint
1. Introduction
In desktop application development and in university education, object-oriented programming (OOP) in languages
like C++ or Java is now common place. OOP has demonstrated its capability for handling complex software development problems in an elegant way and for producing flexible, reusable software components. It has reduced the
development time of new software and simplified the solution of complex software tasks.
Industrial controllers (PLC), on the other hand, are mostly
programmed in the languages of the IEC 61131-3 standard.
While some developers cannot wait to use OOP for PLCprogramming, others may be sceptical about the adequacy
of OOP for their PLC-projects. In order to address both parties, an object-oriented programming tool should satisfy the
following requirements:
Integration in a PLC development environment: Integrated
with the object-oriented programming itself, one should
have integrated configuration of I/Os, direct access to I/Osignals, and online-debugging functionality with variable
forcing and online change. Advantage: PLC-application
development has many specifics, which exiting C++
development tools available for many target-CPUs do not
address.
Multi-paradigm programming: Object-orientation should
be optional. Code programmed in the classical, procedural way should be mixable with object-oriented code.
Advantage: This offers the sceptics a stepwise and reversible transition.
OOP by extension of the IEC: Object-oriented PLC-programming should be supported by extending IEC programming with a small set of standard object-oriented features. Advantage: Not having to learn a completely new
www.atp-international.de atp international 2.2007
SysLibs, I/O-driver
Visualization
11 (1)
24
21
Data server
19 (4)
16 (3)
38 (21)
Others
13 (1)
19 (1)
8 (7)
59
60
classes (superclasses). The commonality of two different specialized classes like CANDRIVE and ANALOGDRIVE can be
factored out into a new common superclass DRIVE.
Advantage: By declaring a classs superclasses, the multitude of the types of different objects in the system is brought
to order. For general superclasses like DRIVE, without
instances by themselves (abstract superclasses), the states
representation and the behaviours implementation does
not need to be defined; it suffices to declare the objects
state and behaviour interface.
2.3 Subclassing
(Class = Specialisation and/
or Generalisation)
Subclassing finally is the highlight of
object-oriented programming. It is an
original, new feature without comparison in procedural programming. There
are three aspects to it:
class hierarchy
class inheritance
subclass polymorphism
61
62
IEC
CoDeSys v3
C++
Java
C#
~ (FBs)
Methods
~ (actions)
Interfaces
Dynamic binding
+/-
+/-
+ (Interfaces)
Constructor / destructor
Properties
~ (variables)
~ (variables)
Access control
Partially abstract classes
Fig. 5: Polymorphic
function.
3. Conclusion
C
T screenshots show
The
t
the
declaration of an array of
i
instances
of the interface IDRIVE
t
the
arrays initialization with
i
instances
of different functionblocks
implementing IDRIVE (see
b
next
n feature)
the
t uniform processing of all these
functionblock
instances by a FORf
loop
over the array
l
It has been shown that all the essential features of standard object-oriented programming are included in CoDeSys
V3. A summary comparison with C++, Java and C# is given in
table 2.
Three more auxiliary features are included in CoDeSys V3,
that we were not able to discuss here for space reasons:
constructor and destructor methods (FB_Init, FB_Exit)
THIS and SUPER in methods
properties (as in C#)
Four common features of object-oriented languages were
not included in CoDeSys V3 in order to keep the OOP extension small and simple:
dynamic allocation (keyword new)
fine-grained access control for variables and methods
(private, protected, internal, public)
partially abstract classes with abstract methods (abstract)
optional dynamic binding (virtual)
63