Ieg.Sequencer 1.4.3

Suggested Alternatives

IegTools.Sequencer

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Ieg.Sequencer --version 1.4.3                
NuGet\Install-Package Ieg.Sequencer -Version 1.4.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ieg.Sequencer" Version="1.4.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ieg.Sequencer --version 1.4.3                
#r "nuget: Ieg.Sequencer, 1.4.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Ieg.Sequencer as a Cake Addin
#addin nuget:?package=Ieg.Sequencer&version=1.4.3

// Install Ieg.Sequencer as a Cake Tool
#tool nuget:?package=Ieg.Sequencer&version=1.4.3                

Ieg.Sequencer in a Nutshell

Ieg.Sequencer allows you to create sequences in code, simple to use and simple to extend.
It helps you get rid of long unreadable if/else statements that represent a sequence of events.

Usage

Configure, build and run a sequence

Configuration .NET 6 style

A simple example configuration for an OnTimer-sequence:

public class OnTimerExample
{
    private ISequenceBuilder SequenceConfig =>
        SequenceBuilder.Create()
            .AddForceState(">Off", () => !LastValue)
            .AddTransition(">Off", "PrepareOn", () => LastValue, () => _sequence.Stopwatch.Restart())
            .AddTransition("PrepareOn", "!On", () => _sequence.Stopwatch.Expired(MyTimeSpan));

Build the sequence

public class OnTimerExample
{
    private ISequence _sequence;
	
    public OnTimerExample() =>
        _sequence = SequenceConfig.Build();
}

Run the sequence

The sequence will be executed in the configuration order .

public class OnTimerExample
{
    public void In(bool value)
    {
        LastValue = value;
        _sequence.Run();
        // or await _sequence.RunAsync();
    }
}

Configuration .NET 5 style

A more complex example configuration for a pump-anti-sticking-sequence:

 private ISequenceBuilder SequenceConfig =>
        SequenceBuilder.Configure(builder =>
        {
            builder.AddForceState(">Paused", () => !_onTimer.Out);
            
            builder.AddTransition(">Paused", "Activated",
                () => _onTimer.Out,
                () => _countStarts = 1);
            
            builder.AddTransition("Activated", "Pump on",
                () => true,
                () => Stopwatch.Restart());
            
            builder.AddTransition("Pump on", "Pump off",
                () => Stopwatch.Expired(_settings.RunTime * _countStarts.Factorial()),
                () =>
                {
                    Stopwatch.Restart();
                    _countStarts++;
                });

            builder.AddTransition("Pump off", "Pump on",
                () => Stopwatch.Expired(_settings.PauseTime) && !sequenceDone());

            builder.AddTransition("Pump off", ">Paused",
                () => Stopwatch.Expired(_settings.PauseTime) && sequenceDone(),
                () => _onTimer.In(false));

            bool sequenceDone() => _countStarts > _settings.PumpStartQuantity;
        });

Config in Detail

  • Force state on condition: builder.AddForceState("ForceState", constraint)

  • State transition on condition (with optional action) builder.AddTransition("FromState", "ToState", constraint, action)

  • Action on state: builder.AddStateAction("State", action)

TODO Documentation

Statuses

Statuses can be defined as strings or enums, internally they will be stored as strings.

State Tags

State-Tags can only be used with string-statuses. For enum-statuses there are other possibilities. (link to ...)

There are available two state tags as prefix for statuses

  • the IgnoreTag '!'
  • and the InitialStateTag '>'

IgnoreTag

Use the IgnoreTag as prefix for an state to tell the Validator not to check this state for counterpart-plausibility.

Example:

 .AddTransition("PrepareOff", "!Off", () => Stopwatch.Expired(MyTimeSpan));

InitialStateTag

Use the InitialStateTag as prefix for an state to tell the Sequence what state to start from.

Example:

 builder.AddForceState(">Paused", () => !_onTimer.Out);

Validation

The sequence will be validated when build. _sequence = builder.Build();

Validation Rules:

  • InitialState must be defined
  • The InitialState must have an counterpart in a StateTransition
  • The Sequence must have at least two steps
  • Each 'NextStep' must have a counterpart StateTransition with an matching 'CurrentState'
  • Each 'CurrentState' must have a counterpart StateTransition with an matching 'NextStep' or ForceState

Validation could be disabled completely:

builder.DisableValidation()

or with specifing statuses that shouldn't be validated:

builder.DisableValidationForStatuses("state1", "state2", ...)

or with the IgnoreTag: TODO Documentation

Extensibility

Write your own customized

  • Descriptors
  • Sequence
  • and Validator

TODO Documentation

Descriptors

Internally the Framework is working with Descriptors (you can write your own customized descriptor). The Descriptors describe what they are supposed to do within the sequence.

There are three default descriptor:

  • The StateTransitionDescriptor
  • The ForceStateDescriptor
  • The StateActionDescriptor

TODO Documentation

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated

Make Sequence open for custom Descriptors