portdic 1.1.77

dotnet add package portdic --version 1.1.77
                    
NuGet\Install-Package portdic -Version 1.1.77
                    
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="portdic" Version="1.1.77" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="portdic" Version="1.1.77" />
                    
Directory.Packages.props
<PackageReference Include="portdic" />
                    
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 portdic --version 1.1.77
                    
#r "nuget: portdic, 1.1.77"
                    
#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 portdic@1.1.77
                    
#: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=portdic&version=1.1.77
                    
Install as a Cake Addin
#tool nuget:?package=portdic&version=1.1.77
                    
Install as a Cake Tool

PortDic

PortDic is a comprehensive .NET library for industrial automation and communication systems. It provides standardized methods for interacting with industrial automation systems, equipment control, and data acquisition with support for multiple communication protocols.

About

PortDic package provides a complete framework for building industrial automation applications with:

  • Annotation-Based Package System: Declarative programming model using attributes for package registration, API generation, and dependency injection
  • Workflow and Flow Control: Sequential and parallel workflow execution with timing control
  • Protocol Integration: Support for SECS/GEM, MQTT, RTSP, and OPC UA protocols
  • Real-time Data Management: Type-safe data setting and retrieval with event-driven architecture
  • Broadcasting System: Multi-protocol communication management
  • REST API Generation: Automatic endpoint creation from annotations
  • Simple Communication Classes: High-performance asynchronous serial port and TCP communication with automatic reconnection

All features are designed for production use with comprehensive error handling, validation, and thread-safe operations.

Key Features

Annotation System

PortDic uses a comprehensive annotation system for declarative programming:

Category Annotations Purpose
Package Management [Package], [Flow], [Import] Class registration and dependency injection
Workflow Control [Step], [StepTimer], [FlowControl] Workflow execution and timing
API Endpoints [API], [Command] REST API generation
Data Handling [Property], [Mapping], [ModelProperty] Data management and transformation
Validation [Valid] Data validation and business rules
Documentation [Comment], [EnumCode] API documentation and enum exposure

Core Capabilities

  • Real-time Data Exchange: Type-safe data setting and retrieval with automatic type conversion
  • Event-Driven Architecture: Comprehensive event handling for status changes and system occurrences
  • Package Injection: Automatic dependency resolution and inter-package communication
  • Flow Control: Complex workflow management with sequential and parallel execution
  • Protocol Support: Industrial communication protocols (SECS/GEM, OPC UA, MQTT, RTSP)
  • Configuration Builder: Fluent interface for protocol configuration
  • Performance Monitoring: Built-in profiling and monitoring capabilities

Simple Communication Classes

  • AsyncSerial: Abstract base class for asynchronous serial port communication with automatic reconnection
  • AsyncTCPServer: Production-ready asynchronous TCP server with client management and 24/7 stability
  • AsyncTCPClient: High-availability asynchronous TCP client with automatic reconnection
  • RingBuffer<T>: Lock-free, zero-allocation ring buffer for high-performance scenarios

How to Use

Initialization and Setup

using portdic;

private static IPortDic port = Port.GetDictionary("sample");

public Form()
{
    InitializeComponent();

    // Event handlers
    port.OnOccurred += Port_OnOccurred;
    port.OnStatusChanged += Port_OnStatusChanged;

    // Start the Port system
    port.Run();
}

Event Handling

Status Change Events
private void Port_OnStatusChanged(object sender, PortStatusArgs e)
{
    switch (e.Status)
    {
        case PortStauts.Initializing:
            break;
        case PortStauts.Running: 
            break;
        case PortStauts.Stopped:
            break;
        case PortStauts.Shutdown:
            break;
        case PortStauts.Failed:
            break;
    }
}
Occurrence Events
private void Port_OnOccurred(object sender, PortEventArgs e)
{
    switch (e.EventType)
    {
        default:
            Console.WriteLine(e.Message);
            break;
    }
}

Package Development with Annotations

Basic Package Example
using portpackage;
using portdatatype;

[Package(typeof(Heater))]
public class Heater
{
    [API(EntryDataType.String, "OnOff")]
    [Comment("Heater power state")]
    public string BulbOnOff { get; set; } = "Off";

    [API(EntryDataType.Float, "Celsius")]
    [Comment("Current temperature")]
    public float RoomTemp1 { get; set; }

    [Valid("Invalid heater state")]
    public bool Valid()
    {
        return BulbOnOff == "On" || BulbOnOff == "Off";
    }
}
Workflow with Flow Control
[Flow(typeof(ProcessFlow))]
public class ProcessFlow
{
    [FlowControl]
    public IFlowControl Flow { get; set; }

    [StepTimer]
    public IStepTimer Timer { get; set; }

    [Step(1, "StartProcess")]
    public void Initialize()
    {
        // Initialization logic
        Flow.Next();
    }

    [Step(2, "ProcessData")]
    public void Process()
    {
        // Processing logic
        Timer.Wait(1000); // Wait 1 second
        Flow.Next();
    }

    [Step(3, "CompleteProcess")]
    public void Complete()
    {
        // Completion logic
    }
}

SET/GET Operations

// Setting values
var ok = port.Set("room1", "BulbOnOff", "On");
if (ok)
{
    Console.WriteLine("ok");
}

// Getting values - returns 'On'
Console.WriteLine(port.Get("room1", "BulbOnOff").Text());

// Alternative syntax
port["room1"].Set("BulbOnOff", "Off");

// Getting values - returns 'Off'
Console.WriteLine(port.Get("room1", "BulbOnOff").Text());

Protocol Integration

GEM (SECS/GEM) Integration
var gem = portdic.BroadCast<GEM>(Port.CreateBuilder(BroadcastType.GEM)
    .Mode(Mode.Active)
    .Listen("127.0.0.1:5000")
    .DeviceID("EQ001")
    .T1(10).T2(5).T3(10)
    .Build());
MQTT Integration
var mqtt = portdic.BroadCast<MQTT>(Port.CreateBuilder(BroadcastType.MQTT)
    .Listen("127.0.0.1:1883")
    .Users(new User("admin", "admin"))
    .AllowRemotes("127.0.0.1")
    .ClientId("PortClient")
    .QoS(1)
    .Build());
OPC UA Integration
var opcua = portdic.BroadCast<OPCUA>(Port.CreateBuilder(BroadcastType.OPCUA)
    .Listen("opc.tcp://localhost:4840")
    .ApplicationInfo("PortApp", "urn:PortApp", "urn:PortApp")
    .SecurityConfig(SecurityMode.SignAndEncrypt, SecurityPolicy.Basic256Sha256)
    .Credentials("admin", "password")
    .Build());

Simple Communication Classes

Serial Port Communication
using portdic.simple;

public class MySerial : AsyncSerial
{
    public MySerial()
    {
        portName = "COM3";
        baudRate = 9600;
        delimiter = "\n";

        this.DataReceived += (sender, message) => 
        {
            Console.WriteLine($"Received: {message}");
        };
        this.ReconnectSuccess += (sender, e) => 
        {
            Console.WriteLine("Reconnected successfully");
        };
    }

    public override void LogWrite(string log)
    {
        Console.WriteLine(log);
    }
}

// Usage
var serial = new MySerial();
await serial.ConnectAsync();
await serial.SendAsync("Hello World!");
TCP Server
using portdic.simple;

public class MyTCPServer : AsyncTCPServer
{
    public MyTCPServer()
    {
        this.port = "5000";
        this.ClientConnected += (sender, client) => 
        {
            Console.WriteLine($"Client connected: {client.RemoteEndPoint}");
        };
        this.DataReceived += async (sender, data) => 
        {
            Console.WriteLine($"Received from {data.Client.Id}: {data.Message}");
            await this.SendToClientAsync(data.Client, "Echo: " + data.Message);
        }; 
        // Usage
        await server.StartAsync();

        // Broadcast to all clients
        await server.BroadcastAsync("Server message");
    }

    public override void LogWrite(string log)
    {
        Console.WriteLine(log);
    }
}
TCP Client
using portdic.simple;

public class MyTCPClient : AsyncTCPClient
{
    public MyTCPClient() 
    {
        this.host = "127.0.0.1";
        this.port = "5000";

        await client.ConnectAsync();
        await client.SendAsync("Hello Server!");
        this.Connected += (sender, e) => 
        {
            Console.WriteLine("Connected to server");
        };
        this.DataReceived += (sender, message) => 
        {
            Console.WriteLine($"Received: {message}");
        };
        this.ReconnectSuccess += (sender, e) => 
        {
            Console.WriteLine("Reconnected successfully");
        };
    }

    public override void LogWrite(string log)
    {
        Console.WriteLine(log);
    }
}

 
Ring Buffer
using portdic.simple;
using System.Text;

// Create a ring buffer with capacity (must be power of 2)
var buffer = new RingBuffer<byte>(1024);

// Producer: Write data
byte[] data = Encoding.UTF8.GetBytes("Hello");
int written = buffer.Write(data);

// Consumer: Read data
byte[] output = new byte[1024];
int bytesRead = buffer.Read(output);
string message = Encoding.UTF8.GetString(output, 0, bytesRead);

// Single item operations
if (buffer.TryWrite(0x42))
{
    if (buffer.TryRead(out byte value))
    {
        Console.WriteLine($"Read: {value}");
    }
}

// Peek without consuming
if (buffer.TryPeek(out byte peekValue))
{
    Console.WriteLine($"Peeked: {peekValue}");
}

Main Types

The main types provided by this library are:

Core Types

  • IPortDic: Main interface for port dictionary communication, real-time data exchange, and protocol management
  • Port: Factory class for creating port dictionary instances
  • PortDic: Core implementation of the port dictionary system

Annotation Attributes

  • [Package]: Attribute for marking classes as Port-managed packages
  • [Flow]: Attribute for defining workflow classes
  • [API]: Attribute for automatic REST API endpoint generation
  • [Step]: Attribute for marking workflow steps
  • [Import]: Attribute for dependency injection
  • [Property]: Attribute for mapping properties to Entry Properties
  • [Valid]: Attribute for data validation and business rules
  • [Command]: Attribute for marking methods as command endpoints

Interfaces

  • IFlowControl: Interface for workflow control and navigation
  • IStepTimer: Interface for timing and scheduling workflow steps
  • IReference: Interface for function references and collections

Simple Communication Classes

  • AsyncSerial: Abstract base class for asynchronous serial port communication with automatic reconnection
  • AsyncTCPServer: Production-ready asynchronous TCP server with client management and 24/7 stability
  • AsyncTCPClient: High-availability asynchronous TCP client with automatic reconnection
  • ClientContext: Represents the context for a connected TCP client, including connection information and message buffering
  • RingBuffer<T>: Lock-free, zero-allocation ring buffer for high-performance scenarios. Thread-safe for single producer and single consumer operations

Additional Documentation

Requirements

  • .NET Standard 2.0 or higher
  • System.IO.Ports package (for serial port functionality)

Feedback & Contributing

PortDic is released as open source. Bug reports and contributions are welcome. Please report issues and submit pull requests through the project repository.

For additional support and examples, refer to the PortDic Documentation.

License

Please refer to the license file included with this package for license information.

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 (1)

Showing the top 1 NuGet packages that depend on portdic:

Package Downloads
Port.SDK

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.77 447 12/9/2025
1.1.76 441 12/8/2025
1.1.75 292 11/12/2025
1.1.74 291 11/11/2025
1.1.73 214 11/9/2025
1.1.72 188 10/14/2025
1.1.71 198 10/13/2025
1.1.70 136 10/12/2025
1.1.69 189 9/30/2025
1.1.68 161 9/28/2025
1.1.67 196 9/25/2025
1.1.66 200 9/23/2025
1.1.65 214 9/22/2025
1.1.64 232 9/21/2025
1.1.63 250 9/14/2025
1.1.62 198 9/10/2025
1.1.61 204 9/7/2025
1.1.59 218 8/31/2025
1.1.58 187 8/21/2025
1.1.57 530 7/24/2025
1.1.56 204 7/8/2025
1.1.55 199 6/3/2025
1.1.54 201 5/25/2025
1.1.52 196 5/11/2025
1.1.51 199 5/8/2025
1.1.50 199 5/8/2025
1.1.49 198 5/5/2025
1.1.48 209 4/2/2025
1.1.47 211 3/20/2025
1.1.46 198 3/17/2025
1.1.45 139 3/15/2025
1.1.44 234 3/9/2025
1.1.43 273 3/5/2025
1.1.42 212 3/3/2025
1.1.41 163 2/27/2025
1.1.40 186 2/24/2025
1.1.39 224 2/16/2025
1.1.38 159 2/10/2025
1.1.36 195 2/9/2025
1.1.35 140 1/14/2025
1.1.34 195 1/12/2025
1.1.33 193 1/7/2025
1.1.32 251 1/5/2025
1.1.31 208 12/4/2024
1.1.30 208 11/26/2024
1.1.29 248 11/24/2024
1.1.28 216 11/21/2024
1.1.27 197 11/17/2024
1.1.26 150 11/16/2024