Override Smart Object elements
Use a derived Smart Object to override elements of a base Smart Object. Overriding an element essentially clears the content for that element. Overriding an element is similar to overriding a method of a class.
You can override the program and all of the routines, tag values, and property values within that program. Use the
override
keyword to override a program. Keep these guidelines in mind when overriding elements.
- Values of tags and properties do not require an explicit override keyword because they are considered instance-specific data. See the Specify unique Smart Object instance values section for more information on instance-specific data.
- The overriding capability follows the IEC 61131-3 rules and conventions on overriding.
- An overridden element must maintain its identity, or signature. A signature consists of the program name and its list of parameters in the same order. Each parameter must have the same parameter’s modifiers, usage, data type and name.
- Overriding an element does not affect references to the element. The references automatically bind to the overridden element.
When you override a program, the override represents a new program implementation:
- The override program is the new implementation and has the override keyword on it.
- The overridden program is the base program for which the new, override program is changing.
- An overridden program provides two choices: copy over the existing content as a starting point, or start with an empty program.
These examples show the code for overriding elements.
In this example, the
extends
keyword indicates that one definition is inheriting from another.Element to override | Example |
---|---|
A program | so MySODef { program p1(input dint in1, output dint out1) { /// program content } } SO MyExtendedSO extends MySODef { override program p1(input dint in1, output dint out1) { // no content from base is inherited when overridden } } |
Provide Feedback