FsmModel 0.0.2

dotnet add package FsmModel --version 0.0.2                
NuGet\Install-Package FsmModel -Version 0.0.2                
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.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FsmModel --version 0.0.2                
#r "nuget: FsmModel, 0.0.2"                
#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.2

// Install FsmModel as a Cake Tool
#tool nuget:?package=FsmModel&version=0.0.2                

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.

  1. Add using directives:
using FsmModel.Dfa;
using FsmModel.Models;
using FsmModel.Utils;
  1. 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");
  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);
  1. 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);  
  1. 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 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.

Version Downloads Last updated
0.0.2 561 2/7/2022
0.0.1 489 1/21/2022