VOOZH about

URL: https://www.nuget.org/packages/Secs.Bert/

⇱ NuGet Gallery | Secs.Bert 1.1.3




Secs.Bert 1.1.3

dotnet add package Secs.Bert --version 1.1.3
 
 
NuGet\Install-Package Secs.Bert -Version 1.1.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="Secs.Bert" Version="1.1.3" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Secs.Bert" Version="1.1.3" />
 
Directory.Packages.props
<PackageReference Include="Secs.Bert" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Secs.Bert --version 1.1.3
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Secs.Bert, 1.1.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.
#:package Secs.Bert@1.1.3
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Secs.Bert&version=1.1.3
 
Install as a Cake Addin
#tool nuget:?package=Secs.Bert&version=1.1.3
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

secs4net

This project is an improvement version from mkjeff/secs4net, which has only optimized some functions and is only for personal learning and use. If you have any questions, please contact me.<br/>

Project Description

SECS-II/HSMS-SS/GEM implementation on .NET. This library provides an easy way to communicate with SEMI-standard compatible devices.

Getting started

Install Nuget package

> dotnet add package Secs.Bert

Configure via .NET dependency injection

Sample code reference

public void ConfigureServices(IServiceCollection services)
{
 // "secs4net" configuration section in the appsettings.json
 // "secs4net": {
 // "DeviceId": 0,
 // "IsActive": true,
 // "IpAddress": "127.0.0.1",
 // "Port": 5000
 // } 
 services.AddSecs4Net<DeviceLogger>(Configuration); 
}

class DeviceLogger : ISecsGemLogger
{
 // implement ISecsGemLogger methods
}

Basic usage

try
{
 var s3f17 = new SecsMessage(3, 17)
 {
 Name = "CreateProcessJob",
 SecsItem = L(
 U4(0),
 L(
 L(
 A("Id"),
 B(0x0D),
 L(
 A("carrier id"),
 L(
 U1(1)),
 L(
 U1(1),
 A("recipe"),
 L()),
 Boolean(true),
 L()))))
 };

 //access list
 s3f17.SecsItem[1][0][0] == A("Id"); 

 foreach(var item in s3f17.SecsItem[1][0][2].Items)
 {

 }

 //access an unmanaged array item
 byte b2 = s3f17.SecsItem[0].FirstValue<byte>(); // with different type
 s3f17.SecsItem[0].FirstValue<byte>() = 0; // change original value 
 byte b3 = s3f17.SecsItem[0].GetFirstValueOrDefault<byte>(fallbackValueWhenItemIsEmpty); 
 Memory<byte> bytes = s3f17.SecsItem[0].GetMemory<byte>();

 // access string item
 string str = s3f17.SecsItem[1][0][0].GetString(); // str = "Id"

 //await the secondary message
 var s3f18 = await secsGem.SendAsync(s3f17); 

 // process message with LINQ
 var query =
 from a in s3f18.SecsItem[3]
 select new {
 num = a.FirstValue<int>(),
 };
}
catch(SecsException)
{
 // exception when
 // T3 timeout
 // device reply SxF0
 // device reply S9Fx
}

Handle primary messages

await foreach (var e in secsGem.GetPrimaryMessageAsync(cancellationToken))
{ 
 using var primaryMsg = e.PrimaryMessage;
 //do something for primary message

 // reply secondary message to device
 using var secondaryMsg = new SecsMessage(...);
 await e.TryReplyAsync(secondaryMsg); 
};

Creates Item via LINQ

using static Secs4Net.Item;

var s16f15 = 
 new SecsMessage(16, 15)
 {
 Name = "CreateProcessJob",
 SecsItem = L(
 U4(0),
 L(
 from pj in tx.ProcessJobs 
 select
 L(
 A(pj.Id),
 B(0x0D),
 L(
 from carrier in pj.Carriers 
 select
 L(
 A(carrier.Id),
 L(
 from slotInfo in carrier.SlotMap 
 select
 U1(slotInfo.SlotNo)))),
 L(
 U1(1),
 A(pj.RecipeId),
 L()),
 Boolean(true),
 L()))));

Change the Item value (restricted)

Basic rule: The Item.Count has been fixed while the item was created.

You can only overwrite values on existing memory. String Item is immutable, coz C# string is immutable as well.

Reuse array for large item values

All unmanaged data Item can created from IMemoryOwner<T> or Memory<T>.

The following sample uses the implementation of IMemoryOwner<T> from Microsoft.Toolkit.HighPerformance that has been referenced internally by secs4net..

var largeArrayOwner = MemoryOwner<int>.Allocate(size: 65535);

// feed the value into largeArrayOwner.Memory or largeArrayOwner.Span
FillLargeArray(largeArrayOwner.Memory);

using var s6f11 = new SecsMessage(6, 11, replyExpected: false)
{
 Name = "LargeDataEvent",
 SecsItem = L(
 L(
 I2(1121),
 A(""),
 I4(largeArrayOwner))), // create Item from largeArrayOwner
};

// apply using on received message as well. coz the item decoded by PipeDecoder also uses MemoryOwner<T> when the data array is big.
using var s6f12 = await secsGem.SendAsync(s6f11);

IMemoryOwner<T>, Item, and SecsMessage have implemented IDisposable don't forget to Dispose it when they don't need anymore. Otherwise, the array will not return to the pool till GC collects.

Since the length of the max encoded bytes in a single non-List Item was 16,777,215(3 bytes), we split raw data into separated items. In that case, creating the Items from sliced Memory<T> is more efficient.

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

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Secs.Bert:

Package Downloads
Secs.Sml.Bert

Package Description

Secs.Json.Bert

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.3 366 5/23/2024
1.1.2 295 5/23/2024
1.1.1 953 1/8/2024
1.1.0 904 1/8/2024
1.0.2 984 12/12/2023