ExecutionOrderAttribute Class |
Namespace: Demo3D.PLC.Rockwell.Emulator.ModuleEmulators
public sealed class ExecutionOrderAttribute : Attribute
The ExecutionOrderAttribute type exposes the following members.
| Name | Description | |
|---|---|---|
| ExecutionOrderAttribute |
Construct an ExecutionOrderAttribute.
|
| Name | Description | |
|---|---|---|
| ExecutionOrder |
The execution order.
|
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() { } }
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() { }
module.ConfigChanged(); // execution order Default-1
module.Ch00.logic1.ConfigChanged();
module.Ch00.logic2.ConfigChanged();
module.Ch00.logic3.ConfigChanged();
module.Ch00.ConfigChanged();