From 8af9d11ee8ad092dd384ab098eb026638f21ab53 Mon Sep 17 00:00:00 2001 From: barnstee Date: Wed, 13 Apr 2022 11:34:10 +0200 Subject: [PATCH] Renamed project and cleaned-up references to MQTT broker. --- AzureFileStorage.cs | 4 +- CommandProcessor.cs | 6 +-- Controllers/BrowserController.cs | 8 +-- Controllers/ConfigController.cs | 4 +- Controllers/DiagController.cs | 2 +- Controllers/HomeController.cs | 2 +- Controllers/PublishedController.cs | 6 +-- Diagnostics.cs | 54 +++++++++---------- Dockerfile | 10 ++-- EventUtils.cs | 2 +- FilterUtils.cs | 2 +- Interfaces/IBrokerClient.cs | 2 +- Interfaces/ICommandProcessor.cs | 2 +- Interfaces/IFileStorage.cs | 2 +- Interfaces/IMessageEncoder.cs | 4 +- Interfaces/IMessageProcessor.cs | 2 +- Interfaces/IMessagePublisher.cs | 2 +- Interfaces/IMessageSource.cs | 2 +- Interfaces/IPublishedNodesFileHandler.cs | 4 +- Interfaces/IUAApplication.cs | 2 +- Interfaces/IUAClient.cs | 4 +- KafkaClient.cs | 10 ++-- LocalFileStorage.cs | 4 +- MQTTClient.cs | 4 +- MessageProcessor.cs | 6 +-- Models/DiagnosticsModel.cs | 2 +- Models/EventModel.cs | 2 +- Models/EventValueModel.cs | 2 +- Models/FilterModel.cs | 2 +- Models/MessageProcessorModel.cs | 2 +- Models/NodePublishingModel.cs | 2 +- Models/PublishNodesInterfaceModel.cs | 2 +- Models/SessionModel.cs | 2 +- Models/UnpublishNodesInterfaceModel.cs | 2 +- Models/UserAuthModeEnum.cs | 2 +- Models/VariableModel.cs | 2 +- MonitoredItemNotification.cs | 6 +-- OpcSessionHelper.cs | 4 +- PeriodicPublishing.cs | 4 +- Program.cs | 2 +- Properties/launchSettings.json | 2 +- PubSubTelemetryEncoder.cs | 6 +-- PublishedNodesFileHandler.cs | 6 +-- README.md | 16 +++--- Settings.cs | 6 +-- Startup.cs | 10 ++-- StatusHub.cs | 2 +- StoreForwardPublisher.cs | 4 +- UAApplication.cs | 8 +-- UAClient.cs | 8 +-- ....Config.xml => UACloudPublisher.Config.xml | 10 ++-- ...ublisher.csproj => UACloudPublisher.csproj | 4 +- UA-MQTT-Publisher.sln => UACloudPublisher.sln | 2 +- Views/Browser/Browse.cshtml | 2 +- Views/Browser/Index.cshtml | 2 +- Views/Config/Index.cshtml | 4 +- Views/Diag/Index.cshtml | 2 +- Views/Home/Index.cshtml | 15 +++--- Views/Published/Index.cshtml | 4 +- Views/Shared/_Layout.cshtml | 6 +-- Views/_ViewImports.cshtml | 4 +- 61 files changed, 155 insertions(+), 156 deletions(-) rename UA-MQTT-Publisher.Config.xml => UACloudPublisher.Config.xml (85%) rename UA-MQTT-Publisher.csproj => UACloudPublisher.csproj (92%) rename UA-MQTT-Publisher.sln => UACloudPublisher.sln (87%) diff --git a/AzureFileStorage.cs b/AzureFileStorage.cs index fae522d..4b68543 100644 --- a/AzureFileStorage.cs +++ b/AzureFileStorage.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Azure.Storage.Blobs; using Azure.Storage.Blobs.Models; @@ -8,7 +8,7 @@ namespace UA.MQTT.Publisher using System.IO; using System.Threading; using System.Threading.Tasks; - using UA.MQTT.Publisher.Interfaces; + using Opc.Ua.Cloud.Publisher.Interfaces; public class AzureFileStorage : IFileStorage { diff --git a/CommandProcessor.cs b/CommandProcessor.cs index c97a4cb..8e39e41 100644 --- a/CommandProcessor.cs +++ b/CommandProcessor.cs @@ -1,15 +1,15 @@  -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Opc.Ua; + using Opc.Ua.Cloud.Publisher.Interfaces; + using Opc.Ua.Cloud.Publisher.Models; using System; using System.Collections.Generic; using System.Linq; using System.Text; - using UA.MQTT.Publisher.Interfaces; - using UA.MQTT.Publisher.Models; public class CommandProcessor : ICommandProcessor { diff --git a/Controllers/BrowserController.cs b/Controllers/BrowserController.cs index abcb5f8..ced45f9 100644 --- a/Controllers/BrowserController.cs +++ b/Controllers/BrowserController.cs @@ -1,5 +1,5 @@ -namespace UA.MQTT.Publisher.Controllers +namespace Opc.Ua.Cloud.Publisher.Controllers { using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -7,13 +7,13 @@ namespace UA.MQTT.Publisher.Controllers using Newtonsoft.Json; using Opc.Ua; using Opc.Ua.Client; + using Opc.Ua.Cloud.Publisher; + using Opc.Ua.Cloud.Publisher.Interfaces; + using Opc.Ua.Cloud.Publisher.Models; using System; using System.Collections.Generic; using System.Diagnostics; using System.Threading.Tasks; - using UA.MQTT.Publisher; - using UA.MQTT.Publisher.Interfaces; - using UA.MQTT.Publisher.Models; public class BrowserController : Controller { diff --git a/Controllers/ConfigController.cs b/Controllers/ConfigController.cs index c787cba..754664a 100644 --- a/Controllers/ConfigController.cs +++ b/Controllers/ConfigController.cs @@ -1,8 +1,8 @@  -namespace UA.MQTT.Publisher.Controllers +namespace Opc.Ua.Cloud.Publisher.Controllers { using Microsoft.AspNetCore.Mvc; - using UA.MQTT.Publisher.Interfaces; + using Opc.Ua.Cloud.Publisher.Interfaces; public class ConfigController : Controller { diff --git a/Controllers/DiagController.cs b/Controllers/DiagController.cs index af12015..76bb04f 100644 --- a/Controllers/DiagController.cs +++ b/Controllers/DiagController.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Controllers +namespace Opc.Ua.Cloud.Publisher.Controllers { using Microsoft.AspNetCore.Mvc; diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs index f49dd94..8f62739 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Controllers +namespace Opc.Ua.Cloud.Publisher.Controllers { using Microsoft.AspNetCore.Mvc; diff --git a/Controllers/PublishedController.cs b/Controllers/PublishedController.cs index 9279ef6..a7f73f4 100644 --- a/Controllers/PublishedController.cs +++ b/Controllers/PublishedController.cs @@ -1,17 +1,17 @@  -namespace UA.MQTT.Publisher.Controllers +namespace Opc.Ua.Cloud.Publisher.Controllers { using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Opc.Ua; + using Opc.Ua.Cloud.Publisher.Interfaces; + using Opc.Ua.Cloud.Publisher.Models; using System; using System.Collections.Generic; using System.IO; using System.Text; - using UA.MQTT.Publisher.Interfaces; - using UA.MQTT.Publisher.Models; public class PublishedController : Controller { diff --git a/Diagnostics.cs b/Diagnostics.cs index 0f1b0a7..481de09 100644 --- a/Diagnostics.cs +++ b/Diagnostics.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.Logging; @@ -8,7 +8,7 @@ namespace UA.MQTT.Publisher using System.Diagnostics; using System.Threading; using System.Threading.Tasks; - using UA.MQTT.Publisher.Models; + using Opc.Ua.Cloud.Publisher.Models; public class Diagnostics { @@ -103,21 +103,21 @@ public async Task RunAsync(CancellationToken cancellationToken = default) _hubClient.AddOrUpdateTableEntry("OPC UA monitored items queue current items", Info.MonitoredItemsQueueCount.ToString()); _hubClient.AddOrUpdateTableEntry("OPC UA monitored item notifications enqueued", Info.EnqueueCount.ToString()); _hubClient.AddOrUpdateTableEntry("OPC UA monitored item notifications enqueue failure", Info.EnqueueFailureCount.ToString()); - _hubClient.AddOrUpdateTableEntry("Messages sent to MQTT broker", Info.SentMessages.ToString()); - _hubClient.AddOrUpdateTableEntry("Last successful MQTT broker message sent @", Info.SentLastTime.ToString()); - _hubClient.AddOrUpdateTableEntry("Total bytes sent to MQTT broker", Info.SentBytes.ToString()); - _hubClient.AddOrUpdateTableEntry("Average MQTT broker message size (bytes)", (Info.SentBytes / (Info.SentMessages == 0 ? 1 : Info.SentMessages)).ToString()); - _hubClient.AddOrUpdateTableEntry("Average MQTT broker message latency (ms)", Info.AverageMessageLatency.ToString(), true); - _hubClient.AddOrUpdateTableEntry("Average MQTT broker messages/second sent", messagesPerSecond.ToString(), true); - _hubClient.AddOrUpdateTableEntry("Average number of notifications batched in MQTT broker message", Info.AverageNotificationsInBrokerMessage.ToString()); + _hubClient.AddOrUpdateTableEntry("Messages sent to broker", Info.SentMessages.ToString()); + _hubClient.AddOrUpdateTableEntry("Last successful broker message sent @", Info.SentLastTime.ToString()); + _hubClient.AddOrUpdateTableEntry("Total bytes sent to broker", Info.SentBytes.ToString()); + _hubClient.AddOrUpdateTableEntry("Average broker message size (bytes)", (Info.SentBytes / (Info.SentMessages == 0 ? 1 : Info.SentMessages)).ToString()); + _hubClient.AddOrUpdateTableEntry("Average broker message latency (ms)", Info.AverageMessageLatency.ToString(), true); + _hubClient.AddOrUpdateTableEntry("Average broker messages/second sent", messagesPerSecond.ToString(), true); + _hubClient.AddOrUpdateTableEntry("Average number of notifications batched in broker message", Info.AverageNotificationsInBrokerMessage.ToString()); _hubClient.AddOrUpdateTableEntry("Average number of OPC UA notifications/second sent", (messagesPerSecond * Info.AverageNotificationsInBrokerMessage).ToString(), true); - _hubClient.AddOrUpdateTableEntry("MQTT broker message send failures", Info.FailedMessages.ToString()); - _hubClient.AddOrUpdateTableEntry("MQTT broker messages too large to send to MQTT broker", Info.TooLargeCount.ToString()); - _hubClient.AddOrUpdateTableEntry("Missed MQTT broker message send intervals", Info.MissedSendIntervalCount.ToString()); + _hubClient.AddOrUpdateTableEntry("broker message send failures", Info.FailedMessages.ToString()); + _hubClient.AddOrUpdateTableEntry("broker messages too large to send to broker", Info.TooLargeCount.ToString()); + _hubClient.AddOrUpdateTableEntry("Missed broker message send intervals", Info.MissedSendIntervalCount.ToString()); _hubClient.AddOrUpdateTableEntry("Number of OPC UA notifications encoded", Info.NumberOfEvents.ToString()); _hubClient.AddOrUpdateTableEntry("Current working set in MB", (Process.GetCurrentProcess().WorkingSet64 / (1024 * 1024)).ToString()); - _hubClient.AddOrUpdateTableEntry("MQTT broker send interval setting (s)", Settings.Instance.DefaultSendIntervalSeconds.ToString()); - _hubClient.AddOrUpdateTableEntry("MQTT broker message size setting (bytes)", Settings.Instance.BrokerMessageSize.ToString()); + _hubClient.AddOrUpdateTableEntry("broker send interval setting (s)", Settings.Instance.DefaultSendIntervalSeconds.ToString()); + _hubClient.AddOrUpdateTableEntry("broker message size setting (bytes)", Settings.Instance.BrokerMessageSize.ToString()); chartValues.Add(Info.AverageMessageLatency.ToString()); chartValues.Add(messagesPerSecond.ToString()); @@ -127,7 +127,7 @@ public async Task RunAsync(CancellationToken cancellationToken = default) // write to the log at 10x slower than the UI diagnostics if (ticks % 10 == 0) { - _logger.LogInformation($"UA-MQTT-Publisher started @ {Info.PublisherStartTime}"); + _logger.LogInformation($"UACloudPublisher started @ {Info.PublisherStartTime}"); _logger.LogInformation($"OPC UA sessions: {Info.NumberOfOpcSessionsConnected}"); _logger.LogInformation($"OPC UA subscriptions: {Info.NumberOfOpcSubscriptionsConnected}"); _logger.LogInformation($"OPC UA monitored items: {Info.NumberOfOpcMonitoredItemsMonitored}"); @@ -135,21 +135,21 @@ public async Task RunAsync(CancellationToken cancellationToken = default) _logger.LogInformation($"OPC UA monitored items queue current items: {Info.MonitoredItemsQueueCount}"); _logger.LogInformation($"OPC UA monitored item notifications enqueued: {Info.EnqueueCount}"); _logger.LogInformation($"OPC UA monitored item notifications enqueue failure: {Info.EnqueueFailureCount}"); - _logger.LogInformation($"Messages sent to MQTT broker: {Info.SentMessages}"); - _logger.LogInformation($"Last successful MQTT broker message sent @: {Info.SentLastTime}"); - _logger.LogInformation($"Total bytes sent to MQTT broker: {Info.SentBytes}"); - _logger.LogInformation($"Average MQTT broker message size (bytes): {Info.SentBytes / (Info.SentMessages == 0 ? 1 : Info.SentMessages)}"); - _logger.LogInformation($"Average MQTT broker message latency (ms): {Info.AverageMessageLatency}"); - _logger.LogInformation($"Average MQTT broker messages/second sent: {messagesPerSecond}"); - _logger.LogInformation($"Average number of notifications batched in MQTT broker message: {Info.AverageNotificationsInBrokerMessage}"); + _logger.LogInformation($"Messages sent to broker: {Info.SentMessages}"); + _logger.LogInformation($"Last successful broker message sent @: {Info.SentLastTime}"); + _logger.LogInformation($"Total bytes sent to broker: {Info.SentBytes}"); + _logger.LogInformation($"Average broker message size (bytes): {Info.SentBytes / (Info.SentMessages == 0 ? 1 : Info.SentMessages)}"); + _logger.LogInformation($"Average broker message latency (ms): {Info.AverageMessageLatency}"); + _logger.LogInformation($"Average broker messages/second sent: {messagesPerSecond}"); + _logger.LogInformation($"Average number of notifications batched in broker message: {Info.AverageNotificationsInBrokerMessage}"); _logger.LogInformation($"Average number of OPC UA notifications/second sent: {messagesPerSecond * Info.AverageNotificationsInBrokerMessage}"); - _logger.LogInformation($"MQTT broker message send failures: {Info.FailedMessages}"); - _logger.LogInformation($"MQTT broker messages too large to send to MQTT broker: {Info.TooLargeCount}"); - _logger.LogInformation($"Missed MQTT broker message send intervals: {Info.MissedSendIntervalCount}"); + _logger.LogInformation($"broker message send failures: {Info.FailedMessages}"); + _logger.LogInformation($"broker messages too large to send to broker: {Info.TooLargeCount}"); + _logger.LogInformation($"Missed broker message send intervals: {Info.MissedSendIntervalCount}"); _logger.LogInformation($"Number of OPC UA notifications encoded: {Info.NumberOfEvents}"); _logger.LogInformation($"Current working set in MB: {Process.GetCurrentProcess().WorkingSet64 / (1024 * 1024)}"); - _logger.LogInformation($"MQTT broker send interval setting (s): {Settings.Instance.DefaultSendIntervalSeconds}"); - _logger.LogInformation($"MQTT broker message size setting (bytes): {Settings.Instance.BrokerMessageSize}"); + _logger.LogInformation($"broker send interval setting (s): {Settings.Instance.DefaultSendIntervalSeconds}"); + _logger.LogInformation($"broker message size setting (bytes): {Settings.Instance.BrokerMessageSize}"); } _lastNumMessagesSent = Info.SentMessages; diff --git a/Dockerfile b/Dockerfile index a1980dc..6a699c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,16 +7,16 @@ EXPOSE 443 FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build WORKDIR /src -COPY ["UA-MQTT-Publisher.csproj", "."] -RUN dotnet restore "./UA-MQTT-Publisher.csproj" +COPY ["UACloudPublisher.csproj", "."] +RUN dotnet restore "./UACloudPublisher.csproj" COPY . . WORKDIR "/src/." -RUN dotnet build "UA-MQTT-Publisher.csproj" -c Release -o /app/build +RUN dotnet build "UACloudPublisher.csproj" -c Release -o /app/build FROM build AS publish -RUN dotnet publish "UA-MQTT-Publisher.csproj" -c Release -o /app/publish +RUN dotnet publish "UACloudPublisher.csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "UA-MQTT-Publisher.dll"] \ No newline at end of file +ENTRYPOINT ["dotnet", "UACloudPublisher.dll"] \ No newline at end of file diff --git a/EventUtils.cs b/EventUtils.cs index 0416a6f..af68424 100644 --- a/EventUtils.cs +++ b/EventUtils.cs @@ -1,5 +1,5 @@ -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using System; using System.Collections.Generic; diff --git a/FilterUtils.cs b/FilterUtils.cs index 8ceecce..303fcd2 100644 --- a/FilterUtils.cs +++ b/FilterUtils.cs @@ -1,5 +1,5 @@ -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Opc.Ua; using Opc.Ua.Client; diff --git a/Interfaces/IBrokerClient.cs b/Interfaces/IBrokerClient.cs index b5cfbd0..c9cb97e 100644 --- a/Interfaces/IBrokerClient.cs +++ b/Interfaces/IBrokerClient.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Interfaces +namespace Opc.Ua.Cloud.Publisher.Interfaces { public interface IBrokerClient { diff --git a/Interfaces/ICommandProcessor.cs b/Interfaces/ICommandProcessor.cs index ae9a7bf..e8f3e17 100644 --- a/Interfaces/ICommandProcessor.cs +++ b/Interfaces/ICommandProcessor.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Interfaces +namespace Opc.Ua.Cloud.Publisher.Interfaces { public interface ICommandProcessor { diff --git a/Interfaces/IFileStorage.cs b/Interfaces/IFileStorage.cs index 0488d1d..4a4e976 100644 --- a/Interfaces/IFileStorage.cs +++ b/Interfaces/IFileStorage.cs @@ -1,5 +1,5 @@ -namespace UA.MQTT.Publisher.Interfaces +namespace Opc.Ua.Cloud.Publisher.Interfaces { using System.Threading; using System.Threading.Tasks; diff --git a/Interfaces/IMessageEncoder.cs b/Interfaces/IMessageEncoder.cs index 14fa4f6..48b5581 100644 --- a/Interfaces/IMessageEncoder.cs +++ b/Interfaces/IMessageEncoder.cs @@ -1,7 +1,7 @@  -namespace UA.MQTT.Publisher.Interfaces +namespace Opc.Ua.Cloud.Publisher.Interfaces { - using UA.MQTT.Publisher.Models; + using Opc.Ua.Cloud.Publisher.Models; public interface IMessageEncoder { diff --git a/Interfaces/IMessageProcessor.cs b/Interfaces/IMessageProcessor.cs index 8689f60..5da3f61 100644 --- a/Interfaces/IMessageProcessor.cs +++ b/Interfaces/IMessageProcessor.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Interfaces +namespace Opc.Ua.Cloud.Publisher.Interfaces { using System; using System.Threading; diff --git a/Interfaces/IMessagePublisher.cs b/Interfaces/IMessagePublisher.cs index ec7f3d3..e9a9294 100644 --- a/Interfaces/IMessagePublisher.cs +++ b/Interfaces/IMessagePublisher.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Interfaces +namespace Opc.Ua.Cloud.Publisher.Interfaces { public interface IMessagePublisher { diff --git a/Interfaces/IMessageSource.cs b/Interfaces/IMessageSource.cs index a45cab3..2053635 100644 --- a/Interfaces/IMessageSource.cs +++ b/Interfaces/IMessageSource.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Interfaces +namespace Opc.Ua.Cloud.Publisher.Interfaces { using Opc.Ua.Client; using System.Collections.Generic; diff --git a/Interfaces/IPublishedNodesFileHandler.cs b/Interfaces/IPublishedNodesFileHandler.cs index a95cf90..5523ff1 100644 --- a/Interfaces/IPublishedNodesFileHandler.cs +++ b/Interfaces/IPublishedNodesFileHandler.cs @@ -1,8 +1,6 @@  -namespace UA.MQTT.Publisher.Interfaces +namespace Opc.Ua.Cloud.Publisher.Interfaces { - using System.Security.Cryptography.X509Certificates; - public interface IPublishedNodesFileHandler { void ParseFile(byte[] content); diff --git a/Interfaces/IUAApplication.cs b/Interfaces/IUAApplication.cs index 331de21..063c2dd 100644 --- a/Interfaces/IUAApplication.cs +++ b/Interfaces/IUAApplication.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Interfaces +namespace Opc.Ua.Cloud.Publisher.Interfaces { using Opc.Ua; using System.Threading; diff --git a/Interfaces/IUAClient.cs b/Interfaces/IUAClient.cs index 6089933..198b513 100644 --- a/Interfaces/IUAClient.cs +++ b/Interfaces/IUAClient.cs @@ -1,7 +1,7 @@  -namespace UA.MQTT.Publisher.Interfaces +namespace Opc.Ua.Cloud.Publisher.Interfaces { - using UA.MQTT.Publisher.Models; + using Opc.Ua.Cloud.Publisher.Models; using System; using System.Collections.Generic; using System.Threading; diff --git a/KafkaClient.cs b/KafkaClient.cs index da2fd49..8a2ee64 100644 --- a/KafkaClient.cs +++ b/KafkaClient.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Configuration +namespace Opc.Ua.Cloud.Publisher.Configuration { using Confluent.Kafka; using Microsoft.Extensions.Logging; @@ -7,7 +7,7 @@ namespace UA.MQTT.Publisher.Configuration using System; using System.Text; using System.Threading; - using UA.MQTT.Publisher.Interfaces; + using Opc.Ua.Cloud.Publisher.Interfaces; public class KafkaClient : IBrokerClient { @@ -79,7 +79,7 @@ public void Connect() } catch (Exception ex) { - _logger.LogCritical("Failed to connect to MQTT broker: " + ex.Message); + _logger.LogCritical("Failed to connect to Kafka broker: " + ex.Message); } } @@ -150,14 +150,14 @@ private void HandleMessage(object state) _logger.LogError("Unknown command received: " + result.Topic); } - // send reponse to MQTT broker + // send reponse to Kafka broker Publish(responsePayload); } catch (Exception ex) { _logger.LogError(ex, "HandleMessageAsync"); - // send error to MQTT broker + // send error to Kafka broker Publish(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ex.Message))); } } diff --git a/LocalFileStorage.cs b/LocalFileStorage.cs index 84994c1..c8ad8b4 100644 --- a/LocalFileStorage.cs +++ b/LocalFileStorage.cs @@ -1,12 +1,12 @@  -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Microsoft.Extensions.Logging; using System; using System.IO; using System.Threading; using System.Threading.Tasks; - using UA.MQTT.Publisher.Interfaces; + using Opc.Ua.Cloud.Publisher.Interfaces; public class LocalFileStorage : IFileStorage { diff --git a/MQTTClient.cs b/MQTTClient.cs index 8944e68..7580ed1 100644 --- a/MQTTClient.cs +++ b/MQTTClient.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Configuration +namespace Opc.Ua.Cloud.Publisher.Configuration { using Microsoft.Extensions.Logging; using MQTTnet; @@ -20,7 +20,7 @@ namespace UA.MQTT.Publisher.Configuration using System.Threading; using System.Threading.Tasks; using System.Web; - using UA.MQTT.Publisher.Interfaces; + using Opc.Ua.Cloud.Publisher.Interfaces; public class MQTTClient : IBrokerClient { diff --git a/MessageProcessor.cs b/MessageProcessor.cs index ff847b5..44c74c0 100644 --- a/MessageProcessor.cs +++ b/MessageProcessor.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Microsoft.Extensions.Logging; using System; @@ -8,8 +8,8 @@ namespace UA.MQTT.Publisher using System.IO; using System.Text; using System.Threading; - using UA.MQTT.Publisher.Interfaces; - using UA.MQTT.Publisher.Models; + using Opc.Ua.Cloud.Publisher.Interfaces; + using Opc.Ua.Cloud.Publisher.Models; public class MessageProcessor : IMessageProcessor { diff --git a/Models/DiagnosticsModel.cs b/Models/DiagnosticsModel.cs index acb23db..d8e2a05 100644 --- a/Models/DiagnosticsModel.cs +++ b/Models/DiagnosticsModel.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Models +namespace Opc.Ua.Cloud.Publisher.Models { using Newtonsoft.Json; using System; diff --git a/Models/EventModel.cs b/Models/EventModel.cs index f0c29c3..0c7aac8 100644 --- a/Models/EventModel.cs +++ b/Models/EventModel.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Models +namespace Opc.Ua.Cloud.Publisher.Models { using Newtonsoft.Json; using System.Collections.Generic; diff --git a/Models/EventValueModel.cs b/Models/EventValueModel.cs index d1861b7..cbe735f 100644 --- a/Models/EventValueModel.cs +++ b/Models/EventValueModel.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Models +namespace Opc.Ua.Cloud.Publisher.Models { using Opc.Ua; diff --git a/Models/FilterModel.cs b/Models/FilterModel.cs index d8c1431..dd98f9d 100644 --- a/Models/FilterModel.cs +++ b/Models/FilterModel.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Models +namespace Opc.Ua.Cloud.Publisher.Models { using Newtonsoft.Json; diff --git a/Models/MessageProcessorModel.cs b/Models/MessageProcessorModel.cs index 2a84d4e..8328c1e 100644 --- a/Models/MessageProcessorModel.cs +++ b/Models/MessageProcessorModel.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Models +namespace Opc.Ua.Cloud.Publisher.Models { using Opc.Ua; using System.Collections.Generic; diff --git a/Models/NodePublishingModel.cs b/Models/NodePublishingModel.cs index d642b80..98b60f6 100644 --- a/Models/NodePublishingModel.cs +++ b/Models/NodePublishingModel.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Models +namespace Opc.Ua.Cloud.Publisher.Models { using Opc.Ua; using System.Collections.Generic; diff --git a/Models/PublishNodesInterfaceModel.cs b/Models/PublishNodesInterfaceModel.cs index 2bb2c97..cececee 100644 --- a/Models/PublishNodesInterfaceModel.cs +++ b/Models/PublishNodesInterfaceModel.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Models +namespace Opc.Ua.Cloud.Publisher.Models { using Newtonsoft.Json; using Newtonsoft.Json.Converters; diff --git a/Models/SessionModel.cs b/Models/SessionModel.cs index 18fbc2e..fcfa328 100644 --- a/Models/SessionModel.cs +++ b/Models/SessionModel.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Models +namespace Opc.Ua.Cloud.Publisher.Models { public class SessionModel { diff --git a/Models/UnpublishNodesInterfaceModel.cs b/Models/UnpublishNodesInterfaceModel.cs index 8c15884..c3265f0 100644 --- a/Models/UnpublishNodesInterfaceModel.cs +++ b/Models/UnpublishNodesInterfaceModel.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Models +namespace Opc.Ua.Cloud.Publisher.Models { using Newtonsoft.Json; using System.Collections.Generic; diff --git a/Models/UserAuthModeEnum.cs b/Models/UserAuthModeEnum.cs index 70c1f27..33d2706 100644 --- a/Models/UserAuthModeEnum.cs +++ b/Models/UserAuthModeEnum.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Models +namespace Opc.Ua.Cloud.Publisher.Models { public enum UserAuthModeEnum { diff --git a/Models/VariableModel.cs b/Models/VariableModel.cs index 5575159..353f58b 100644 --- a/Models/VariableModel.cs +++ b/Models/VariableModel.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher.Models +namespace Opc.Ua.Cloud.Publisher.Models { using Newtonsoft.Json; diff --git a/MonitoredItemNotification.cs b/MonitoredItemNotification.cs index 80abe51..5b372ee 100644 --- a/MonitoredItemNotification.cs +++ b/MonitoredItemNotification.cs @@ -1,13 +1,13 @@  -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Microsoft.Extensions.Logging; using Opc.Ua; using Opc.Ua.Client; using System; using System.Collections.Generic; - using UA.MQTT.Publisher.Interfaces; - using UA.MQTT.Publisher.Models; + using Opc.Ua.Cloud.Publisher.Interfaces; + using Opc.Ua.Cloud.Publisher.Models; public class MonitoredItemNotification : IMessageSource { diff --git a/OpcSessionHelper.cs b/OpcSessionHelper.cs index 846d88c..f4f6054 100644 --- a/OpcSessionHelper.cs +++ b/OpcSessionHelper.cs @@ -1,12 +1,12 @@  -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Opc.Ua; using Opc.Ua.Client; + using Opc.Ua.Cloud.Publisher.Interfaces; using System; using System.Collections.Concurrent; using System.Threading.Tasks; - using UA.MQTT.Publisher.Interfaces; public class OpcSessionCacheData { diff --git a/PeriodicPublishing.cs b/PeriodicPublishing.cs index f137ac2..e389fae 100644 --- a/PeriodicPublishing.cs +++ b/PeriodicPublishing.cs @@ -1,12 +1,12 @@  -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Microsoft.Extensions.Logging; using Opc.Ua; using Opc.Ua.Client; + using Opc.Ua.Cloud.Publisher.Models; using System; using System.Threading; - using UA.MQTT.Publisher.Models; public class PeriodicPublishing: IDisposable { diff --git a/Program.cs b/Program.cs index db9b4d5..a78d851 100644 --- a/Program.cs +++ b/Program.cs @@ -1,5 +1,5 @@ -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index 21a1a19..b62bc91 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -15,7 +15,7 @@ "ASPNETCORE_ENVIRONMENT": "Development" } }, - "UA-MQTT-Publisher": { + "UACloudPublisher": { "commandName": "Project", "launchBrowser": true, "environmentVariables": { diff --git a/PubSubTelemetryEncoder.cs b/PubSubTelemetryEncoder.cs index ed3df63..2cf4cba 100644 --- a/PubSubTelemetryEncoder.cs +++ b/PubSubTelemetryEncoder.cs @@ -1,11 +1,11 @@  -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Microsoft.Extensions.Logging; using Opc.Ua; + using Opc.Ua.Cloud.Publisher.Interfaces; + using Opc.Ua.Cloud.Publisher.Models; using System; - using UA.MQTT.Publisher.Interfaces; - using UA.MQTT.Publisher.Models; public class PubSubTelemetryEncoder : IMessageEncoder { diff --git a/PublishedNodesFileHandler.cs b/PublishedNodesFileHandler.cs index 9eabf46..1b50bc2 100644 --- a/PublishedNodesFileHandler.cs +++ b/PublishedNodesFileHandler.cs @@ -1,15 +1,15 @@ -namespace UA.MQTT.Publisher.Configuration +namespace Opc.Ua.Cloud.Publisher.Configuration { using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Opc.Ua; + using Opc.Ua.Cloud.Publisher.Interfaces; + using Opc.Ua.Cloud.Publisher.Models; using System; using System.Collections.Generic; using System.Text; - using UA.MQTT.Publisher.Interfaces; - using UA.MQTT.Publisher.Models; public class PublishedNodesFileHandler : IPublishedNodesFileHandler { diff --git a/README.md b/README.md index 3cc29e7..b0032c7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# UA-MQTT-Publisher +# UA Cloud Publisher A cross-platform OPC UA cloud publisher reference implementation leveraging OPC UA PubSub over MQTT. It runs in a Docker container on standard Docker hosts or on Kubernetes and comes with an easy-to-use web user interface. @@ -9,7 +9,7 @@ A cross-platform OPC UA cloud publisher reference implementation leveraging OPC * UI for connecting to, browsing of, reading nodes from and publishing nodes from an OPC UA server * Uses OPC UA PubSub JSON encoding * Uses plain MQTT broker as publishing endpoint -* Can optionally use plain Kafka broker as publishing endpoint +* Optionally uses plain Kafka broker as publishing endpoint * OPC UA Variables publishing * OPC UA Alarms, Conditions & other events publishing * OPC UA Event filtering @@ -18,7 +18,7 @@ A cross-platform OPC UA cloud publisher reference implementation leveraging OPC * UI for displaying the list of publishes nodes * UI for displaying diagnostic information * UI for configuration -* Publishing from the cloud via a connected MQTT broker +* Publishing from the cloud via a broker * Publishing on data changes or on regular intervals * Supports publishednodes.json imput file format * Support for storing configuration files locally or in the cloud @@ -26,7 +26,7 @@ A cross-platform OPC UA cloud publisher reference implementation leveraging OPC ## Usage -Docker containers are automatically built and published. Simply run the UA-MQTT-Publisher on a Docker-enabled computer via: +Docker containers are automatically built and published. Simply run the UA Cloud Publisher on a Docker-enabled computer via: `docker run -p 80:80 ghcr.io/barnstee/ua-mqtt-publisher:main` @@ -34,15 +34,15 @@ And then point your browser to . ### Persisting Settings -UA-MQTT-Publisher settings and published nodes configuration can be persisted in the Cloud across Docker container restarts by running: +UA Cloud Publisher settings and published nodes configuration can be persisted in the Cloud across Docker container restarts by running: -`docker run -e STORAGE_TYPE="Azure" -e STORAGE_CONNECTION_STRING="yourAzureBlobStorageConnectionString" -p 80:80 ghcr.io/barnstee/ua-mqtt-publisher:main` +`docker run -e STORAGE_TYPE="Azure" -e STORAGE_CONNECTION_STRING="yourAzureBlobStorageConnectionString" -p 80:80 ghcr.io/barnstee/UACloudPublisher:main` And then point your browser again to . ## Optional Environment Variables -* LOG_FILE_PATH - path to the log file to use. Default is /app/Logs/UA-MQTT-Publisher.log (in the Docker container). +* LOG_FILE_PATH - path to the log file to use. Default is /app/Logs/UACloudPublisher.log (in the Docker container). * STORAGE_TYPE - type of storage to use for settings and configuration files. Current options are "Azure". Default is local file storage (under /app/settings/ in the Docker container). * STORAGE_CONNECTION_STRING - when using STORAGE_TYPE, specifies the connection string to the cloud storage. * USE_KAFKA - use a Kafka broker instead of an MQTT broker to send messages to and receive commands from. @@ -238,4 +238,4 @@ Response: ## Build Status -[![Docker](https://github.com/barnstee/UA-MQTT-Publisher/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/barnstee/UA-MQTT-Publisher/actions/workflows/docker-publish.yml) +[![Docker](https://github.com/barnstee/UA-CloudPublisher/actions/workflows/docker-publish.yml/badge.svg)](https://github.com/barnstee/UA-CloudPublisher/actions/workflows/docker-publish.yml) diff --git a/Settings.cs b/Settings.cs index b35e2c3..0be7a2e 100644 --- a/Settings.cs +++ b/Settings.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Microsoft.Extensions.Logging; using Newtonsoft.Json; @@ -7,7 +7,7 @@ namespace UA.MQTT.Publisher using System.IO; using System.Text; using System.Threading.Tasks; - using UA.MQTT.Publisher.Interfaces; + using Opc.Ua.Cloud.Publisher.Interfaces; public class Settings { @@ -117,7 +117,7 @@ public async void Save() public bool UseTLS { get; set; } = true; - public string PublisherName { get; set; } = "UA-MQTT-Publisher"; + public string PublisherName { get; set; } = "UACloudPublisher"; public uint InternalQueueCapacity { get; set; } = 1000; // records diff --git a/Startup.cs b/Startup.cs index 30b0e54..b82900e 100644 --- a/Startup.cs +++ b/Startup.cs @@ -1,5 +1,5 @@ -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -10,8 +10,8 @@ namespace UA.MQTT.Publisher using System; using System.IO; using System.Threading.Tasks; - using UA.MQTT.Publisher.Configuration; - using UA.MQTT.Publisher.Interfaces; + using Opc.Ua.Cloud.Publisher.Configuration; + using Opc.Ua.Cloud.Publisher.Interfaces; public class Startup { @@ -36,7 +36,7 @@ public void ConfigureServices(IServiceCollection services) string logFilePath = Configuration["LOG_FILE_PATH"]; if (string.IsNullOrEmpty(logFilePath)) { - logFilePath = "./Logs/UA-MQTT-Publisher.log"; + logFilePath = "./Logs/UACloudPublisher.log"; } services.AddLogging(logging => { @@ -120,7 +120,7 @@ public void Configure(IApplicationBuilder app, // kick off the task to show periodic diagnostic info _ = Task.Run(() => Diagnostics.Singleton.RunAsync()); - // connect to MQTT broker + // connect to broker subscriber.Connect(); // run the telemetry engine diff --git a/StatusHub.cs b/StatusHub.cs index bd7b1ab..f91e65e 100644 --- a/StatusHub.cs +++ b/StatusHub.cs @@ -1,5 +1,5 @@  -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Microsoft.AspNetCore.SignalR; using System; diff --git a/StoreForwardPublisher.cs b/StoreForwardPublisher.cs index 0548a9f..0cc5d43 100644 --- a/StoreForwardPublisher.cs +++ b/StoreForwardPublisher.cs @@ -1,12 +1,12 @@  -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; - using UA.MQTT.Publisher.Interfaces; + using Opc.Ua.Cloud.Publisher.Interfaces; public class StoreForwardPublisher : IMessagePublisher { diff --git a/UAApplication.cs b/UAApplication.cs index 731f559..0ea899f 100644 --- a/UAApplication.cs +++ b/UAApplication.cs @@ -1,15 +1,15 @@  -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Microsoft.Extensions.Logging; using Opc.Ua; + using Opc.Ua.Cloud.Publisher.Interfaces; using Opc.Ua.Configuration; using System; using System.Globalization; using System.IO; using System.Threading; using System.Threading.Tasks; - using UA.MQTT.Publisher.Interfaces; public class UAApplication : IUAApplication { @@ -28,7 +28,7 @@ public async Task CreateAsync(CancellationToken cancellationToken = default) { if (string.IsNullOrEmpty(Settings.Instance.PublisherName)) { - Settings.Instance.PublisherName = "UA-MQTT-Publisher"; + Settings.Instance.PublisherName = "UACloudPublisher"; } try @@ -85,7 +85,7 @@ public async Task CreateAsync(CancellationToken cancellationToken = default) _uaApplicationInstance = new ApplicationInstance { ApplicationName = Settings.Instance.PublisherName, ApplicationType = ApplicationType.Client, - ConfigSectionName = "UA-MQTT-Publisher" + ConfigSectionName = "UACloudPublisher" }; await _uaApplicationInstance.LoadApplicationConfiguration(false).ConfigureAwait(false); diff --git a/UAClient.cs b/UAClient.cs index cc232e9..f322dd0 100644 --- a/UAClient.cs +++ b/UAClient.cs @@ -1,11 +1,13 @@ -namespace UA.MQTT.Publisher +namespace Opc.Ua.Cloud.Publisher { using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Opc.Ua; using Opc.Ua.Client; using Opc.Ua.Client.ComplexTypes; + using Opc.Ua.Cloud.Publisher.Interfaces; + using Opc.Ua.Cloud.Publisher.Models; using System; using System.Collections.Generic; using System.IO; @@ -13,8 +15,6 @@ namespace UA.MQTT.Publisher using System.Text; using System.Threading; using System.Threading.Tasks; - using UA.MQTT.Publisher.Interfaces; - using UA.MQTT.Publisher.Models; public class UAClient : IUAClient { @@ -558,7 +558,7 @@ public async Task PublishNodeAsync(NodePublishingModel nodeToPublish, Cancellati nodeToPublish.ExpandedNodeId, session.ConfiguredEndpoint.EndpointUrl); - _logger.LogError("OPC UA ServiceResultException is {result}. Please check your UA-MQTT-Publisher configuration for this node.", sre.Result); + _logger.LogError("OPC UA ServiceResultException is {result}. Please check your UA Cloud Publisher configuration for this node.", sre.Result); break; default: diff --git a/UA-MQTT-Publisher.Config.xml b/UACloudPublisher.Config.xml similarity index 85% rename from UA-MQTT-Publisher.Config.xml rename to UACloudPublisher.Config.xml index 3fd34ec..86e5f1e 100644 --- a/UA-MQTT-Publisher.Config.xml +++ b/UACloudPublisher.Config.xml @@ -4,15 +4,15 @@ xmlns="http://opcfoundation.org/UA/SDK/Configuration.xsd" schemaLocation="./Schema/ApplicationConfiguration.xsd" > - UA.MQTT.Publisher - urn:localhost:UA-MQTT-Publisher + UACloudPublisher + urn:localhost:UACloudPublisher https://github.com/azure/iot-edge-opc-publisher Client_1 Directory ./pki/own - CN=UA-MQTT-Publisher, C=US, S=Arizona, O=OPCFoundation, DC=localhost + CN=UACloudPublisher, C=US, S=Arizona, O=OPCFoundation, DC=localhost Directory @@ -63,8 +63,8 @@ - - ./Logs/UA-MQTT-Publisher.log + + ./Logs/UACloudPublisher.log true