FsmModel 0.0.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package FsmModel --version 0.0.1
NuGet\Install-Package FsmModel -Version 0.0.1
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="FsmModel" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FsmModel --version 0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FsmModel, 0.0.1"
#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 FsmModel as a Cake Addin #addin nuget:?package=FsmModel&version=0.0.1 // Install FsmModel as a Cake Tool #tool nuget:?package=FsmModel&version=0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FsmModel
FsmModel is a library for creating and using Finite Automata (Finite State Machines).
Usage
Example of an automaton solving the problem of summing two binary numbers.
- Add using directives:
using FsmModel.Dfa;
using FsmModel.Models;
using FsmModel.Utils;
- Create States, InSignals and OutSignals:
var q0 = new State("q0");
var q1 = new State("q1");
var s0 = new InSignal("00");
var s1 = new InSignal("01");
var s2 = new InSignal("10");
var s3 = new InSignal("11");
var r0 = new OutSignal("0");
var r1 = new OutSignal("1");
- Create DFA Model:
var dfa = new DfaModel()
.AddTrasition(q0, q0, s0, true, r0, () => Console.WriteLine("0"))
.AddTrasition(q0, q0, s1, true, r1, () => Console.WriteLine("1"))
.AddTrasition(q0, q0, s2, true, r1, () => Console.WriteLine("1"))
.AddTrasition(q0, q1, s3, true, r0, () => Console.WriteLine("0"))
.AddTrasition(q1, q0, s0, true, r1, () => Console.WriteLine("1"))
.AddTrasition(q1, q1, s1, true, r0, () => Console.WriteLine("0"))
.AddTrasition(q1, q1, s2, true, r0, () => Console.WriteLine("0"))
.AddTrasition(q1, q1, s3, true, r1, () => Console.WriteLine("1"))
.SetInitialState(q0)
.SetIsNeedJournal(true)
.SetIsNeedActionsDeactivate(false);
- Send a sequence of signals to the input of the DFA machine:
dfa.Act(s3)
.Act(s0)
.Act(s2)
.Act(s3)
.Act(s1)
.Act(s3)
.Act(s0)
.Act(s0);
- Print journal:
JournalUtils.GetPrettyJournalContent(dfa.GetJournal())
.ForEach(row => Console.WriteLine(row));
The printed journal will look something like this
---------------------------------
|Time |Signal |State |Out msg|
---------------------------------
|0 |11 |q0 |0 |
---------------------------------
|1 |00 |q1 |1 |
---------------------------------
|2 |10 |q0 |1 |
---------------------------------
|3 |11 |q0 |0 |
---------------------------------
|4 |01 |q1 |0 |
---------------------------------
|5 |11 |q1 |1 |
---------------------------------
|6 |00 |q1 |1 |
---------------------------------
|7 |00 |q0 |0 |
---------------------------------
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net5.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on FsmModel:
Package | Downloads |
---|---|
FsmModel.Loaders
FsmModel.Loaders is a library with tools for loading transition tables from files and convert it into DFA models. |
GitHub repositories
This package is not used by any popular GitHub repositories.