Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickRitchie committed Nov 30, 2023
1 parent 215e8e8 commit 4a7d944
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 27 deletions.
9 changes: 7 additions & 2 deletions MTConnect.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-AgentProcesso
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-AgentModule-MqttRelay", "agent\Modules\MTConnect.NET-AgentModule-MqttRelay\MTConnect.NET-AgentModule-MqttRelay.csproj", "{CB2E7F5A-55D5-43BD-ABC8-145E8436BE88}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-AgentModule-HttpAdapter", "agent\Modules\MTConnect.NET-AgentModule-HttpAdapter\MTConnect.NET-AgentModule-HttpAdapter.csproj", "{2104A3F5-A157-4763-8B90-38CD103D93D8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-AgentModule-HttpClientAdapter", "agent\Modules\MTConnect.NET-AgentModule-HttpAdapter\MTConnect.NET-AgentModule-HttpClientAdapter.csproj", "{2104A3F5-A157-4763-8B90-38CD103D93D8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-AgentModule-HttpServer", "agent\Modules\MTConnect.NET-AgentModule-HttpServer\MTConnect.NET-AgentModule-HttpServer.csproj", "{7025F1F6-F914-4830-8171-30872F184918}"
EndProject
Expand All @@ -98,7 +98,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Clients", "Clients", "{4558
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}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MTConnect.NET-Client-HTTP", "clients\MTConnect.NET-Client-HTTP\MTConnect.NET-Client-HTTP.csproj", "{619557F6-A8D5-4995-9D96-0E3174221FC6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0712EA0C-EC0D-42EE-9CDD-148893A018F8}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,35 @@ Other features of MTConnect.NET :
- Full client support for requesting data from any MTConnect Agent (Probe, Current, Sample Stream, Assets, etc.). See [Clients](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-HTTP/Clients/Rest) for more information.
- (In-Progress) [Models](https://github.com/TrakHound/MTConnect.NET/tree/master/src/MTConnect.NET-Models/Models) framework for setting and accessing data using an object model as opposed to DataItem ID's and Types

## Download

- [Agent Releases](https://github.com/TrakHound/MTConnect.NET/releases)
- [Adapter Source](https://github.com/TrakHound/MTConnect.NET/tree/version-6.0/adapter/MTConnect.NET-Adapter)
- [Nuget](https://www.nuget.org/packages/MTConnect.NET#readme-body-tab)

## Usage

### Create Agent
```c#
using MTConnect.Agents;

var agent = new MTConnectAgent();
```

### Create Adapter
```c#
using MTConnect.Adapters;

var adapter = new ShdrAdapter();
```

### Create Client
```c#
using MTConnect.Clients;

var client = new MTConnectHttpClient();
```

## Agent Applications

#### Recommended (Windows / Linux)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<ProjectReference Include="..\..\libraries\MTConnect.NET-JSON\MTConnect.NET-JSON.csproj" />
<ProjectReference Include="..\..\libraries\MTConnect.NET-Services\MTConnect.NET-Services.csproj" />
<ProjectReference Include="..\..\libraries\MTConnect.NET-XML\MTConnect.NET-XML.csproj" />
<ProjectReference Include="..\Modules\MTConnect.NET-AgentModule-HttpAdapter\MTConnect.NET-AgentModule-HttpAdapter.csproj" />
<ProjectReference Include="..\Modules\MTConnect.NET-AgentModule-HttpAdapter\MTConnect.NET-AgentModule-HttpClientAdapter.csproj" />
<ProjectReference Include="..\Modules\MTConnect.NET-AgentModule-HttpServer\MTConnect.NET-AgentModule-HttpServer.csproj" />
<ProjectReference Include="..\Modules\MTConnect.NET-AgentModule-MqttAdapter\MTConnect.NET-AgentModule-MqttAdapter.csproj" />
<ProjectReference Include="..\Modules\MTConnect.NET-AgentModule-MqttRelay\MTConnect.NET-AgentModule-MqttRelay.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ protected virtual void OnPrintHelpArguments() { }

private void ModuleLoaded(object sender, IMTConnectAgentModule module)
{
_applicationLogger.Debug($"[Application] : Module Loaded : " + module.GetType().Name);
_applicationLogger.Info($"[Application] : Module Loaded : " + module.GetType().Name);
}

private void ModuleLogReceived(object sender, MTConnectLogLevel logLevel, string message)
Expand All @@ -648,7 +648,7 @@ private void ModuleLogReceived(object sender, MTConnectLogLevel logLevel, string

private void ProcessorLoaded(object sender, IMTConnectAgentProcessor processor)
{
_applicationLogger.Debug($"[Application] : Processor Loaded : " + processor.GetType().Name);
_applicationLogger.Info($"[Application] : Processor Loaded : " + processor.GetType().Name);
}

private void DevicesRequested(string deviceName)
Expand Down
22 changes: 11 additions & 11 deletions agent/MTConnect.NET-Applications-Agents/NLog.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

<!--Console-->
<target name="logconsole" xsi:type="Console" />

<!--Application Log File-->
<target xsi:type="File" name="application-file" fileName="logs\application-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />

<!--Agent Log File-->
<target xsi:type="File" name="agent-file" fileName="logs\agent-${shortdate}.log"
Expand All @@ -15,14 +19,10 @@
<target xsi:type="File" name="agent-validation-file" fileName="logs\agent-validation-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />

<!--HTTP Log File-->
<target xsi:type="File" name="http-file" fileName="logs\http-${shortdate}.log"
<!--Module Log File-->
<target xsi:type="File" name="module-file" fileName="logs\module-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id:whenEmpty=0}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}" />

<!--Client Log File-->
<target xsi:type="File" name="client-file" fileName="logs\client-${shortdate}.log"
layout="${longdate} | ${event-properties:item=EventId_Id:whenEmpty=0} | ${uppercase:${level}} | ${logger} | ${message} ${exception:format=tostring}" />

</targets>

<!-- rules to map from logger name to target -->
Expand All @@ -31,17 +31,17 @@
<!--Write to Console-->
<logger name="*" minlevel="Debug" writeTo="logconsole" />

<!--Application Logger-->
<logger name="application-logger" minlevel="Info" writeTo="application-file" final="true" />

<!--Agent Logger-->
<logger name="agent-logger" minlevel="Info" writeTo="agent-file" final="true" />

<!--Agent Validation Logger (Used to log Data Validation Errors)-->
<logger name="agent-validation-logger" minlevel="Warning" writeTo="agent-validation-file" final="true" />

<!--HTTP Logger-->
<logger name="http-logger" minlevel="Info" writeTo="http-file" final="true" />

<!--Client Logger-->
<logger name="client-logger" minlevel="Info" writeTo="client-file" final="true" />
<!--Module Logger-->
<logger name="module-logger" minlevel="Info" writeTo="module-file" final="true" />

<!--Skip non-critical Microsoft logs and so log only own logs (BlackHole) -->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace MTConnect.Modules
{
public class Module : MTConnectAgentModule
{
public const string ConfigurationTypeId = "http-adapter";
public const string ConfigurationTypeId = "http-client";

private readonly Logger _clientLogger = LogManager.GetLogger("http-adapter-logger");
private readonly HttpClientConfiguration _configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace MTConnect
{
public class Module : MTConnectAgentModule
{
public const string ConfigurationTypeId = "mqtt2-relay";
public const string ConfigurationTypeId = "mqtt-relay";

private readonly MTConnectMqttServer _server;
private readonly ModuleConfiguration _configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ private void Load()
lock (_lock) _functions.Clear();

var dir = GetDirectory();
var files = Directory.GetFiles(dir, $"*{_defaultExtension}");
if (!files.IsNullOrEmpty())
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
if (Directory.Exists(dir))
{
foreach (var file in files)
var files = Directory.GetFiles(dir, $"*{_defaultExtension}");
if (!files.IsNullOrEmpty())
{
LoadEngine(file);
foreach (var file in files)
{
LoadEngine(file);
}
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions libraries/MTConnect.NET-MQTT/MTConnectMqttServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public void Start()
var response = _mtconnectAgent.GetDevicesResponseDocument(device.Uuid);
if (response != null)
{
Console.WriteLine($"Probe : {device.Uuid}");
if (ProbeReceived != null) ProbeReceived.Invoke(device, response);
}
}
Expand Down Expand Up @@ -78,7 +77,6 @@ private async Task CurrentWorker()
var response = _mtconnectAgent.GetDeviceStreamsResponseDocument(device.Uuid);
if (response != null)
{
Console.WriteLine($"Current : {device.Uuid}");
if (CurrentReceived != null) CurrentReceived.Invoke(device, response);
}
}
Expand Down Expand Up @@ -108,7 +106,6 @@ private async Task SampleWorker()
var response = _mtconnectAgent.GetDeviceStreamsResponseDocument(device.Uuid, _lastSequence, -1, 1000); // COUNT = 1000 ??
if (response != null && response.ObservationCount > 0)
{
Console.WriteLine($"Sample : {device.Uuid} : {_lastSequence}");
if (SampleReceived != null) SampleReceived.Invoke(device, response);
if (response.LastObservationSequence >= lastSequence) lastSequence = response.LastObservationSequence + 1;
}
Expand All @@ -132,8 +129,6 @@ private void DeviceAdded(object sender, IDevice device)
var response = _mtconnectAgent.GetDevicesResponseDocument(device.Uuid);
if (response != null)
{
Console.WriteLine("Probe");

if (ProbeReceived != null) ProbeReceived.Invoke(device, response);
}
}
Expand Down

0 comments on commit 4a7d944

Please sign in to comment.