Section 6 Program Code Issues
Re-use of Code
3BSE042835-600
89
Re-use of Code
Names of object types on the same hierarchical level must be unique.
Code re-use requires more variables and execution time, but facilitates maintenance.
Internal (hidden) function block types should be used to improve the structuring of
object types. It is also possible to implement functions by means of placing sub
control module types within both Control Module- and Function Block types.
Control Modules within Function Block Types are mutually sorted. The following
shall be considered for internal types (yet, the benefits of efficient code should also
be recognized).
Avoid use of very simple function blocks for structuring or re-use of code; the
overhead caused by the resulting variable copying will be higher than writing the
equivalent code in ST.
Naming of object type formal instances is realized by omitting the Name part from
the corresponding type name. For example, if the object type name is PIDFaceplate,
the instance name becomes Faceplate, BiCore becomes Core, and so on. It is
desirable to have short, but descriptive, path strings in, for example error messages
including variable names. Object type instances that can appear in loop messages
should always have a descriptive name.
Simple data types should be used for parameters as far as possible in internal
Function Block types since this gives more general types that can be used in
different contexts with good performance. Only in rare cases may structured data
types prove to be a more efficient solution. When using structured data types of
direction Out, variable copying can be eliminated by declaring these as In_Out or
By_ref. Instead of variable copying, a single pointer (address) reference is used for
the entire structured data type and its components, something that saves memory
and execution time. Note that these benefits are not valid for simple data types
which should be declared according to their actual use. In-parameters should be
declared as In and Out-parameters as Out. Also note that by declaring a parameter
as In_Out, the compiler will consider it to be both read and written by the function
block. This might cause some problems when using sub function blocks; in control
modules as well as in function blocks. For control modules and diagram type
instances it will affect the code sorting and might cause sorting loops. For function
blocks it will be impossible to connect the parameter to a surrounding parameter
declared as In.
Summary of Contents for AC 800M
Page 2: ......
Page 3: ...AC 800M Library Object Style Guide System Version 6 0...
Page 12: ...Related Documentation About This User Manual 12 3BSE042835 600...
Page 18: ...Naming Convention Section 1 Libraries 18 3BSE042835 600...
Page 108: ...SIL Mark Restrictions Section 6 Program Code Issues 108 3BSE042835 600...
Page 116: ...Standard Library Parameters Appendix A Names and Abbreviations 116 3BSE042835 600...
Page 119: ......