2 Simple machine
This "UML class diagram" sample illustrates the basic functionality of the UML class diagram based on a machine with object-oriented programming.
Note that the modules have not been functionally implemented. The sample is designed to describe the functionalities of the UML class diagram and to demonstrate them using an exemplary program structure. |
With the help of the class diagram, the structure of a PLC program can be created, extended and modified.
In addition, as in this sample, the structure of a PLC program can be documented with the help of the class diagram and easily understood on the basis of this graphic.
Sample project: TF1910_UmlCD_Sample2_SimpleMachine.zip
Machine modules
The application has the following levels and modules.
Machine level: machine (FB_Machine)
Subsystem level: ejection (FB_Ejector)
Submodule level: cylinder with or without hardware feedback signal (FB_Cylinder, FB_CylinderFeedback)
Inheritance
Since all these function blocks have common features (common data and functionalities), a base class is provided where these common features are implemented once for all function blocks. These implementations are passed on to the subclasses via the inheritance mechanism offered by object-oriented programming.
- The four machine modules extend FB_ModuleRoot.
Furthermore, the cylinder with feedback functionality represents an extension of the cylinder without this functionality. Therefore, inheritance is also used here.
- FB_CylinderFeedback extends FB_Cylinder.
Interface
To define the requirements for different cylinder types, the basic methods and properties that a cylinder must provide are defined in an interface.
- I_Cylinder defines the cylinder requirements.
- FB_Cylinder implements I_Cylinder.
Instantiation
- MAIN instantiates FB_Machine.
- FB_Machine instantiates FB_Ejector twice, since the machine has two ejector modules.
- FB_Ejector instantiates I_Cylinder, FB_Cylinder and FB_CylinderFeedback. As an example, only one cylinder is active at a time, either the cylinder with feedback functionality or the cylinder without feedback functionality. The interface variable iCylinder is assigned the currently active cylinder instance. This allows the active cylinder to be controlled in a generalized manner via the interface variable.
- FB_ModuleRoot instantiates ST_Error.