-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added Example projects - Updated to support "/" base path for pattern matching
- Loading branch information
1 parent
7f84036
commit 8d48cd5
Showing
33 changed files
with
801 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
using System.Reflection; | ||
|
||
[assembly: AssemblyVersion("0.1.1")] | ||
[assembly: AssemblyFileVersion("0.1.1")] | ||
[assembly: AssemblyVersion("0.2.0")] | ||
[assembly: AssemblyFileVersion("0.2.0")] | ||
[assembly: AssemblyCompany("TrakHound Inc.")] | ||
[assembly: AssemblyCopyright("Copyright (c) 2024 TrakHound Inc., All Rights Reserved.")] |
15 changes: 15 additions & 0 deletions
15
...es/Example-Middleware-DeadbandPeriodFilter/Example-Middleware-DeadbandPeriodFilter.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RootNamespace>Example_Middleware_DeadbandPeriodFilter</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Uns.NET\Uns.NET.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
38 changes: 38 additions & 0 deletions
38
examples/Example-Middleware-DeadbandPeriodFilter/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Uns; | ||
|
||
|
||
// Declare a new UnsClient | ||
var client = new UnsClient(); | ||
|
||
|
||
// Add Period Deadband Filter Middleware for 10 seconds | ||
client.AddMiddleware(new UnsDeadbandPeriodMiddleware(TimeSpan.FromSeconds(10))); | ||
|
||
|
||
// Add MQTT (Plain) Connection | ||
var mqttConnection = new UnsMqttConnection("localhost", 1883); | ||
mqttConnection.AddSubscription("#"); | ||
client.AddConnection(mqttConnection); | ||
|
||
|
||
// Subscribe to any Path | ||
var consumer = client.Subscribe("#"); | ||
consumer.Received += (c, o) => | ||
{ | ||
Console.WriteLine("-------------------------"); | ||
Console.WriteLine($"Path = {o.Path}"); | ||
Console.WriteLine($"Connection.Id = {o.Connection?.Id}"); | ||
Console.WriteLine($"Connection.Type = {o.Connection?.Type}"); | ||
Console.WriteLine($"ContentType = {o.ContentType}"); | ||
Console.WriteLine($"Content = {System.Text.Encoding.UTF8.GetString(o.Content)}"); | ||
Console.WriteLine($"Timestamp = {o.Timestamp.ToString("o")}"); | ||
}; | ||
|
||
// Start Client | ||
await client.Start(); | ||
|
||
Console.WriteLine("Press a key to stop.."); | ||
Console.ReadLine(); | ||
|
||
// Stop Client | ||
await client.Stop(); |
15 changes: 15 additions & 0 deletions
15
...ples/Example-Middleware-DeadbandValueFilter/Example-Middleware-DeadbandValueFilter.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RootNamespace>Example_Middleware_DeadbandValueFilter</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Uns.NET\Uns.NET.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
38 changes: 38 additions & 0 deletions
38
examples/Example-Middleware-DeadbandValueFilter/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Uns; | ||
|
||
|
||
// Declare a new UnsClient | ||
var client = new UnsClient(); | ||
|
||
|
||
// Add Period Deadband Filter Middleware for 10 seconds | ||
client.AddMiddleware(new UnsDeadbandValueMiddleware(5)); | ||
|
||
|
||
// Add MQTT (Plain) Connection | ||
var mqttConnection = new UnsMqttConnection("localhost", 1883); | ||
mqttConnection.AddSubscription("#"); | ||
client.AddConnection(mqttConnection); | ||
|
||
|
||
// Subscribe to any Path | ||
var consumer = client.Subscribe("#"); | ||
consumer.Received += (c, o) => | ||
{ | ||
Console.WriteLine("-------------------------"); | ||
Console.WriteLine($"Path = {o.Path}"); | ||
Console.WriteLine($"Connection.Id = {o.Connection?.Id}"); | ||
Console.WriteLine($"Connection.Type = {o.Connection?.Type}"); | ||
Console.WriteLine($"ContentType = {o.ContentType}"); | ||
Console.WriteLine($"Content = {System.Text.Encoding.UTF8.GetString(o.Content)}"); | ||
Console.WriteLine($"Timestamp = {o.Timestamp.ToString("o")}"); | ||
}; | ||
|
||
// Start Client | ||
await client.Start(); | ||
|
||
Console.WriteLine("Press a key to stop.."); | ||
Console.ReadLine(); | ||
|
||
// Stop Client | ||
await client.Stop(); |
15 changes: 15 additions & 0 deletions
15
examples/Example-Middleware-RBE/Example-Middleware-RBE.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RootNamespace>Example_RBE</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Uns.NET\Uns.NET.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Uns; | ||
|
||
|
||
// Declare a new UnsClient | ||
var client = new UnsClient(); | ||
|
||
|
||
// Add RBE Middleware | ||
client.AddMiddleware(new UnsReportByExceptionMiddleware()); | ||
|
||
|
||
// Add MQTT (Plain) Connection | ||
var mqttConnection = new UnsMqttConnection("localhost", 1883); | ||
mqttConnection.AddSubscription("#"); | ||
client.AddConnection(mqttConnection); | ||
|
||
|
||
// Subscribe to any Path | ||
var consumer = client.Subscribe("#"); | ||
consumer.Received += (c, o) => | ||
{ | ||
Console.WriteLine("-------------------------"); | ||
Console.WriteLine($"Path = {o.Path}"); | ||
Console.WriteLine($"Connection.Id = {o.Connection?.Id}"); | ||
Console.WriteLine($"Connection.Type = {o.Connection?.Type}"); | ||
Console.WriteLine($"ContentType = {o.ContentType}"); | ||
Console.WriteLine($"Content = {System.Text.Encoding.UTF8.GetString(o.Content)}"); | ||
Console.WriteLine($"Timestamp = {o.Timestamp.ToString("o")}"); | ||
}; | ||
|
||
// Start Client | ||
await client.Start(); | ||
|
||
Console.WriteLine("Press a key to stop.."); | ||
Console.ReadLine(); | ||
|
||
// Stop Client | ||
await client.Stop(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RootNamespace>Example_Mqtt_Publish</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Uns.NET\Uns.NET.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Uns; | ||
|
||
|
||
// Declare a new UnsClient | ||
var client = new UnsClient(); | ||
|
||
|
||
// Add MQTT (Plain) Connection | ||
var mqttConnection = new UnsMqttConnection("localhost", 1883); | ||
mqttConnection.AddDestination(); | ||
client.AddConnection(mqttConnection); | ||
|
||
|
||
// Start Client | ||
await client.Start(); | ||
|
||
while (true) | ||
{ | ||
Console.WriteLine("Enter Event Path (ex. Site/Cell/PLC/Temperature).."); | ||
var eventPath = Console.ReadLine(); | ||
|
||
Console.WriteLine("Enter Event Content (ex. 45.2).."); | ||
var eventContent = Console.ReadLine(); | ||
|
||
await client.Publish(eventPath, eventContent); | ||
} |
15 changes: 15 additions & 0 deletions
15
examples/Example-Mqtt-Subscribe/Example-Mqtt-Subscribe.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RootNamespace>Example_Plain_Mqtt</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Uns.NET\Uns.NET.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Uns; | ||
|
||
|
||
// Declare a new UnsClient | ||
var client = new UnsClient(); | ||
|
||
|
||
// Add MQTT (Plain) Connection | ||
var mqttConnection = new UnsMqttConnection("localhost", 1883); | ||
mqttConnection.AddSubscription("Site/#"); | ||
client.AddConnection(mqttConnection); | ||
|
||
|
||
// Subscribe to any Path | ||
var consumer = client.Subscribe("#"); | ||
consumer.Received += (c, o) => | ||
{ | ||
Console.WriteLine("-------------------------"); | ||
Console.WriteLine($"Path = {o.Path}"); | ||
Console.WriteLine($"Connection.Id = {o.Connection?.Id}"); | ||
Console.WriteLine($"Connection.Type = {o.Connection?.Type}"); | ||
Console.WriteLine($"ContentType = {o.ContentType}"); | ||
Console.WriteLine($"Content = {System.Text.Encoding.UTF8.GetString(o.Content)}"); | ||
Console.WriteLine($"Timestamp = {o.Timestamp.ToString("o")}"); | ||
}; | ||
|
||
// Start Client | ||
await client.Start(); | ||
|
||
Console.WriteLine("Press a key to stop.."); | ||
Console.ReadLine(); | ||
|
||
// Stop Client | ||
await client.Stop(); |
15 changes: 15 additions & 0 deletions
15
examples/Example-Multiple-Connections-Publish/Example-Multiple-Connections-Publish.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RootNamespace>Example_Multiple_Connections</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Uns.NET\Uns.NET.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Uns; | ||
|
||
|
||
// Declare a new UnsClient | ||
var client = new UnsClient(); | ||
|
||
|
||
// Add MQTT (Plain) Connection | ||
var mqttConnection = new UnsMqttConnection("localhost", 1883); | ||
mqttConnection.AddDestination("Site/ERP"); | ||
mqttConnection.AddDestination("Site/Cell/MES"); | ||
client.AddConnection(mqttConnection); | ||
|
||
|
||
// Add Sparkplug Connection | ||
var spBConnection = new UnsSparkplugConnection("localhost", 1883, "test-publish"); | ||
spBConnection.AddDevice("Site/Cell/PLC"); | ||
client.AddConnection(spBConnection); | ||
|
||
|
||
await client.Start(); | ||
|
||
while (true) | ||
{ | ||
Console.WriteLine("Enter Event Path (ex. Site/Cell/PLC/Temperature).."); | ||
var eventPath = Console.ReadLine(); | ||
|
||
Console.WriteLine("Enter Event Content (ex. 45.2).."); | ||
var eventContent = Console.ReadLine(); | ||
|
||
await client.Publish(eventPath, eventContent); | ||
} |
15 changes: 15 additions & 0 deletions
15
...ples/Example-Multiple-Connections-Subscribe/Example-Multiple-Connections-Subscribe.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RootNamespace>Example_Multiple_Connections_Subscribe</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Uns.NET\Uns.NET.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
41 changes: 41 additions & 0 deletions
41
examples/Example-Multiple-Connections-Subscribe/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Uns; | ||
|
||
|
||
// Declare a new UnsClient | ||
var client = new UnsClient(); | ||
|
||
|
||
// Add MQTT (Plain) Connection | ||
var mqttConnection = new UnsMqttConnection("localhost", 1883); | ||
mqttConnection.AddSubscription("Site/ERP/#"); | ||
mqttConnection.AddSubscription("Site/Cell/MES/#"); | ||
client.AddConnection(mqttConnection); | ||
|
||
|
||
// Add Sparkplug Connection | ||
var spBConnection = new UnsSparkplugConnection("localhost", 1883, "test-subscribe"); | ||
spBConnection.AddApplication("Site/Cell/PLC"); | ||
client.AddConnection(spBConnection); | ||
|
||
|
||
// Subscribe to any Path | ||
var consumer = client.Subscribe("#"); | ||
consumer.Received += (c, o) => | ||
{ | ||
Console.WriteLine("-------------------------"); | ||
Console.WriteLine($"Path = {o.Path}"); | ||
Console.WriteLine($"Connection.Id = {o.Connection?.Id}"); | ||
Console.WriteLine($"Connection.Type = {o.Connection?.Type}"); | ||
Console.WriteLine($"ContentType = {o.ContentType}"); | ||
Console.WriteLine($"Content = {System.Text.Encoding.UTF8.GetString(o.Content)}"); | ||
Console.WriteLine($"Timestamp = {o.Timestamp.ToString("o")}"); | ||
}; | ||
|
||
// Start Client | ||
await client.Start(); | ||
|
||
Console.WriteLine("Press a key to stop.."); | ||
Console.ReadLine(); | ||
|
||
// Stop Client | ||
await client.Stop(); |
Oops, something went wrong.