Click or drag to resize

ExecutionOrderAttribute Class

Specifies the ExecutionOrder attribute for event methods.
Inheritance Hierarchy
SystemObject
  SystemAttribute
    Demo3D.PLC.Rockwell.Emulator.ModuleEmulatorsExecutionOrderAttribute

Namespace:  Demo3D.PLC.Rockwell.Emulator.ModuleEmulators
Assembly:  PLC (in PLC.dll) Version: 18.03.00
Syntax
C#
public sealed class ExecutionOrderAttribute : Attribute

The ExecutionOrderAttribute type exposes the following members.

Constructors
  NameDescription
Public methodExecutionOrderAttribute
Construct an ExecutionOrderAttribute.
Top
Properties
  NameDescription
Public propertyExecutionOrder
The execution order.
Top
Fields
  NameDescription
Public fieldStatic memberDefault
The default execution order.
Top
Remarks

Where a module emulator script has more than one event function (ComputeInputs, ProcessOutputs, ConfigChanged, etc), the default order of execution of the events is well defined.

In this example, IConfigChanged.ConfigChanged() appears in several places in the script.

class MyDigitalModule : IConfigChanged {
    class SomeLogic : IConfigChanged {
        public virtual void ConfigChanged() { }
    }

    class ChannelBaseClass : IConfigChanged {
        [Auto] SomeLogic logic1;

        public virtual void ConfigChanged() { }
    }

    class Channel : ChannelBaseClass {
        [Auto] SomeLogic logic2;
        [Auto] SomeLogic logic3;
    }

    [Auto] Channel Ch00;

    public virtual void ConfigChanged() { }
}
The order of execution follows the order in which fields are encountered. If a field is itself an [Auto] class field, then its sub-properties are traversed before continuing to the next field. (Ie depth-first.)

Therefore in the example above, the default order of execution is

module.Ch00.logic1.ConfigChanged();
module.Ch00.logic2.ConfigChanged();
module.Ch00.logic3.ConfigChanged();
module.Ch00.ConfigChanged();
module.ConfigChanged();

The ExecutionOrder attribute can be used to explicitly define the order of execution. The default execution position of a method is defined by Default. You can force a method to execute earlier or later than its default order by specifying an number correspondingly less than or greater than Default.

For example, if the ConfigChanged method on the module class was rewritten:

[ExecutionOrder(ExecutionOrderAttribute.Default -1)]
public virtual void ConfigChanged() { }
then it would execute earlier than normal, before the other methods:
module.ConfigChanged();                 // execution order Default-1
module.Ch00.logic1.ConfigChanged();
module.Ch00.logic2.ConfigChanged();
module.Ch00.logic3.ConfigChanged();
module.Ch00.ConfigChanged();

See Also