Skip to content

Commit

Permalink
Added HTTP Client Example Project
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickRitchie committed Nov 29, 2023
1 parent 791dcec commit 2011c8d
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 16 deletions.
24 changes: 24 additions & 0 deletions MTConnect.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-Adapter", "ad
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-Agent", "agent\MTConnect.NET-Agent\MTConnect.NET-Agent.csproj", "{04171268-E71D-45F5-9B14-C325AB522BD1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Clients", "Clients", "{4558F2F3-D5B7-49DE-AC9C-8E778C4D3585}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-Client-SHDR", "clients\MTConnect.NET-Client-SHDR\MTConnect.NET-Client-SHDR.csproj", "{3B6E6874-ADB2-4C59-9E65-C13693466920}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MTConnect.NET-Client-HTTP", "clients\MTConnect.NET-Client-HTTP\MTConnect.NET-Client-HTTP.csproj", "{619557F6-A8D5-4995-9D96-0E3174221FC6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -342,6 +348,22 @@ Global
{04171268-E71D-45F5-9B14-C325AB522BD1}.Package|Any CPU.Build.0 = Debug|Any CPU
{04171268-E71D-45F5-9B14-C325AB522BD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04171268-E71D-45F5-9B14-C325AB522BD1}.Release|Any CPU.Build.0 = Release|Any CPU
{3B6E6874-ADB2-4C59-9E65-C13693466920}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B6E6874-ADB2-4C59-9E65-C13693466920}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B6E6874-ADB2-4C59-9E65-C13693466920}.Docker|Any CPU.ActiveCfg = Debug|Any CPU
{3B6E6874-ADB2-4C59-9E65-C13693466920}.Docker|Any CPU.Build.0 = Debug|Any CPU
{3B6E6874-ADB2-4C59-9E65-C13693466920}.Package|Any CPU.ActiveCfg = Debug|Any CPU
{3B6E6874-ADB2-4C59-9E65-C13693466920}.Package|Any CPU.Build.0 = Debug|Any CPU
{3B6E6874-ADB2-4C59-9E65-C13693466920}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B6E6874-ADB2-4C59-9E65-C13693466920}.Release|Any CPU.Build.0 = Release|Any CPU
{619557F6-A8D5-4995-9D96-0E3174221FC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{619557F6-A8D5-4995-9D96-0E3174221FC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{619557F6-A8D5-4995-9D96-0E3174221FC6}.Docker|Any CPU.ActiveCfg = Debug|Any CPU
{619557F6-A8D5-4995-9D96-0E3174221FC6}.Docker|Any CPU.Build.0 = Debug|Any CPU
{619557F6-A8D5-4995-9D96-0E3174221FC6}.Package|Any CPU.ActiveCfg = Debug|Any CPU
{619557F6-A8D5-4995-9D96-0E3174221FC6}.Package|Any CPU.Build.0 = Debug|Any CPU
{619557F6-A8D5-4995-9D96-0E3174221FC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{619557F6-A8D5-4995-9D96-0E3174221FC6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -380,6 +402,8 @@ Global
{ACD5D3A4-0474-4E24-BF18-1F699CDB101F} = {0F01D2F5-0CFA-4DAE-A0FD-5733D291F6FB}
{26DB5DDD-5D08-4BB7-82EA-16595332CF24} = {5C1723BE-3FA0-4C64-AFEC-4343ADCEAE2B}
{04171268-E71D-45F5-9B14-C325AB522BD1} = {C3791CDD-9446-4584-AA80-0C41FCB63B88}
{3B6E6874-ADB2-4C59-9E65-C13693466920} = {4558F2F3-D5B7-49DE-AC9C-8E778C4D3585}
{619557F6-A8D5-4995-9D96-0E3174221FC6} = {4558F2F3-D5B7-49DE-AC9C-8E778C4D3585}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CC13D3AD-18BF-4695-AB2A-087EF0885B20}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@
<ProjectReference Include="..\..\..\libraries\MTConnect.NET-SHDR\MTConnect.NET-SHDR.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="README.md">
<PackagePath>\</PackagePath>
<Pack>True</Pack>
</None>
</ItemGroup>

</Project>
26 changes: 26 additions & 0 deletions adapter/Modules/MTConnect.NET-AdapterModule-SHDR/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
![MTConnect.NET Logo](https://raw.githubusercontent.com/TrakHound/MTConnect.NET/dev/img/mtconnect-net-03-md.png)

# MTConnect SHDR Adapter Module

## Description
This Adapter Module implements the SHDR Protocol to send data to an MTConnect Agent

## Configuration
```yaml
- shdr:
port: 7878
deviceKey: M12346
```
* `port` - The port number to read from.

* `deviceKey` - The UUID or Name of the Device to send data for.


## Contribution / Feedback
- Please use the [Issues](https://github.com/TrakHound/MTConnect.NET/issues) tab to create issues for specific problems that you may encounter
- Please feel free to use the [Pull Requests](https://github.com/TrakHound/MTConnect.NET/pulls) tab for any suggested improvements to the source code
- For any other questions or feedback, please contact TrakHound directly at **[email protected]**.

## License
This application and it's source code is licensed under the [MIT License](https://choosealicense.com/licenses/mit/) and is free to use.
15 changes: 15 additions & 0 deletions clients/MTConnect.NET-Client-HTTP/MTConnect.NET-Client-HTTP.csproj
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>MTConnect.NET_Client_HTTP</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\libraries\MTConnect.NET-HTTP\MTConnect.NET-HTTP.csproj" />
<ProjectReference Include="..\..\libraries\MTConnect.NET-XML\MTConnect.NET-XML.csproj" />
</ItemGroup>

</Project>
62 changes: 62 additions & 0 deletions clients/MTConnect.NET-Client-HTTP/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
namespace MTConnect.Clients.HTTP
{
internal class Program
{
static void Main(string[] args)
{
DocumentClient();
EntityClient();

Console.ReadLine();
}

static void DocumentClient()
{
var client = new MTConnectHttpClient("localhost", 5000);

client.ProbeReceived += (s, response) =>
{
Console.WriteLine(response.Devices.Count());
};

client.CurrentReceived += (s, response) =>
{
Console.WriteLine(response.Streams.Count());
};

client.SampleReceived += (s, response) =>
{
Console.WriteLine(response.Streams.Count());
};

client.AssetsReceived += (s, response) =>
{
Console.WriteLine(response.Assets.Count());
};

client.Start();
}

static void EntityClient()
{
var client = new MTConnectHttpClient("localhost", 5000);

client.DeviceReceived += (s, device) =>
{
Console.WriteLine(device.Uuid);
};

client.ObservationReceived += (s, observation) =>
{
Console.WriteLine(observation.Uuid);
};

client.AssetReceived += (s, asset) =>
{
Console.WriteLine(asset.Uuid);
};

client.Start();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>MTConnect.Client.Shdr</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\MTConnect.NET-SHDR\MTConnect.NET-SHDR.csproj" />
<ProjectReference Include="..\..\libraries\MTConnect.NET-SHDR\MTConnect.NET-SHDR.csproj" />
</ItemGroup>

</Project>
38 changes: 24 additions & 14 deletions clients/MTConnect.NET-Client-SHDR/Program.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
using MTConnect.Shdr;

var client = new ShdrClient("localhost", 7878);
client.Connected += (s, e) =>
namespace MTConnect.Clients.SHDR
{
Console.WriteLine("Connection Established");
};
client.ProtocolReceived += (s, line) =>
{
Console.WriteLine(line);
};
client.Disconnected += (s, e) =>
{
Console.WriteLine("Disconnected");
};
client.Start();
internal class Program
{
static void Main(string[] args)
{
var client = new ShdrClient("localhost", 7878);
client.Connected += (s, e) =>
{
Console.WriteLine("Connection Established");
};
client.ProtocolReceived += (s, line) =>
{
Console.WriteLine(line);
};
client.Disconnected += (s, e) =>
{
Console.WriteLine("Disconnected");
};
client.Start();

Console.ReadLine();

client.Stop();
client.Stop();
}
}
}

0 comments on commit 2011c8d

Please sign in to comment.