Skip to content

Commit

Permalink
Cosmetic
Browse files Browse the repository at this point in the history
  • Loading branch information
luiscantero committed Apr 28, 2022
1 parent 5bae26d commit 5dceaf4
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static OpcPlc.OpcApplicationConfiguration;
Expand Down Expand Up @@ -50,7 +49,7 @@ public static class Program
/// <summary>
/// Service returning <see cref="DateTime"/> values and <see cref="Timer"/> instances. Mocked in tests.
/// </summary>
public static TimeService TimeService = new TimeService();
public static TimeService TimeService = new();

/// <summary>
/// A flag indicating when the server is up and ready to accept connections.
Expand Down Expand Up @@ -160,13 +159,13 @@ public static async Task MainAsync(string[] args, CancellationToken cancellation

LogLogo();

Logger.Information($"Current directory is: {Directory.GetCurrentDirectory()}");
Logger.Information($"Log file is: {Path.GetFullPath(LogFileName)}");
Logger.Information($"Log level is: {LogLevel}");
Logger.Information($"Current directory: {Directory.GetCurrentDirectory()}");
Logger.Information($"Log file: {Path.GetFullPath(LogFileName)}");
Logger.Information($"Log level: {LogLevel}");

//show version
var fileVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
Logger.Information($"{ProgramName} V{fileVersion.ProductMajorPart}.{fileVersion.ProductMinorPart}.{fileVersion.ProductBuildPart} starting up...");
Logger.Information($"{ProgramName} V{fileVersion.ProductMajorPart}.{fileVersion.ProductMinorPart}.{fileVersion.ProductBuildPart} starting up ...");
Logger.Debug($"Informational version: V{(Attribute.GetCustomAttribute(Assembly.GetEntryAssembly(), typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute)?.InformationalVersion}");

using var host = CreateHostBuilder(args);
Expand All @@ -181,7 +180,7 @@ public static async Task MainAsync(string[] args, CancellationToken cancellation
}
catch (Exception ex)
{
Logger.Fatal(ex, "OPC UA server failed unexpectedly.");
Logger.Fatal(ex, "OPC UA server failed unexpectedly");
}

Logger.Information("OPC UA server exiting...");
Expand Down Expand Up @@ -213,9 +212,9 @@ private static void StartWebServer(IHost host)
host.Start();
Logger.Information($"Web server started on port {WebServerPort}");
}
catch (Exception)
catch (Exception e)
{
Logger.Error($"Could not start web server on port {WebServerPort}");
Logger.Error($"Could not start web server on port {WebServerPort}: {e.Message}");
}
}

Expand Down Expand Up @@ -253,19 +252,19 @@ private static async Task ConsoleServerAsync(CancellationToken cancellationToken
Logger.Information($"Starting server on endpoint {plcApplicationConfiguration.ServerConfiguration.BaseAddresses[0]} ...");
Logger.Information("Simulation settings are:");
Logger.Information($"One simulation phase consists of {SimulationCycleCount} cycles");
Logger.Information($"One cycle takes {SimulationCycleLength} milliseconds");
Logger.Information($"Reference Test Simulation is {(AddReferenceTestSimulation ? "enabled" : "disabled")}");
Logger.Information($"Simple Events is {(AddSimpleEventsSimulation ? "enabled" : "disabled")}");
Logger.Information($"Alarms is {(AddAlarmSimulation ? "enabled" : "disabled")}");
Logger.Information($"Deterministic Alarms is {(DeterministicAlarmSimulationFile != null ? "enabled" : "disabled")}");
Logger.Information($"One cycle takes {SimulationCycleLength} ms");
Logger.Information($"Reference Test Simulation: {(AddReferenceTestSimulation ? "Enabled" : "Disabled")}");
Logger.Information($"Simple Events: {(AddSimpleEventsSimulation ? "Enabled" : "Disabled")}");
Logger.Information($"Alarms: {(AddAlarmSimulation ? "Enabled" : "Disabled")}");
Logger.Information($"Deterministic Alarms: {(DeterministicAlarmSimulationFile != null ? "Enabled" : "Disabled")}");

Logger.Information($"Anonymous authentication: {(DisableAnonymousAuth ? "disabled" : "enabled")}");
Logger.Information($"Username/Password authentication: {(DisableUsernamePasswordAuth ? "disabled" : "enabled")}");
Logger.Information($"Certificate authentication: {(DisableCertAuth ? "disabled" : "enabled")}");
Logger.Information($"Anonymous authentication: {(DisableAnonymousAuth ? "Disabled" : "Enabled")}");
Logger.Information($"Username/Password authentication: {(DisableUsernamePasswordAuth ? "Disabled" : "Enabled")}");
Logger.Information($"Certificate authentication: {(DisableCertAuth ? "Disabled" : "Enabled")}");

PlcServer = new PlcServer(TimeService);
PlcServer.Start(plcApplicationConfiguration);
Logger.Information("OPC UA Server started.");
Logger.Information("OPC UA Server started");

PlcSimulation = new PlcSimulation(PlcServer);
PlcSimulation.Start();
Expand All @@ -288,7 +287,7 @@ await PnJsonHelper.PrintPublisherConfigJsonAsync(
}

Ready = true;
Logger.Information("PLC Simulation started. Press CTRL-C to exit.");
Logger.Information("PLC simulation started, press Ctrl+C to exit ...");

// wait for Ctrl-C

Expand Down

0 comments on commit 5dceaf4

Please sign in to comment.