portdic 1.1.77
dotnet add package portdic --version 1.1.77
NuGet\Install-Package portdic -Version 1.1.77
<PackageReference Include="portdic" Version="1.1.77" />
<PackageVersion Include="portdic" Version="1.1.77" />
<PackageReference Include="portdic" />
paket add portdic --version 1.1.77
#r "nuget: portdic, 1.1.77"
#:package portdic@1.1.77
#addin nuget:?package=portdic&version=1.1.77
#tool nuget:?package=portdic&version=1.1.77
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 managementPort: Factory class for creating port dictionary instancesPortDic: 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 navigationIStepTimer: Interface for timing and scheduling workflow stepsIReference: Interface for function references and collections
Simple Communication Classes
AsyncSerial: Abstract base class for asynchronous serial port communication with automatic reconnectionAsyncTCPServer: Production-ready asynchronous TCP server with client management and 24/7 stabilityAsyncTCPClient: High-availability asynchronous TCP client with automatic reconnectionClientContext: Represents the context for a connected TCP client, including connection information and message bufferingRingBuffer<T>: Lock-free, zero-allocation ring buffer for high-performance scenarios. Thread-safe for single producer and single consumer operations
Additional Documentation
- PortDic .NET Integration Guide - Comprehensive documentation with examples
- System.IO.Ports Documentation
- System.Net.Sockets Documentation
Requirements
- .NET Standard 2.0 or higher
- System.IO.Ports package (for serial port functionality)
Related Packages
- System.IO.Ports - Required 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 | Versions 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. |
-
.NETStandard 2.0
- CommunityToolkit.Mvvm (>= 8.4.0)
- FodyHelpers (>= 6.8.2)
- Microsoft.CSharp (>= 4.7.0)
- System.IO.Ports (>= 10.0.0)
- System.ServiceProcess.ServiceController (>= 9.0.3)
- System.Text.Json (>= 9.0.0)
- Tommy (>= 3.1.2)
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 |