Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ variables:
buildConfiguration: 'Release'
major: 5
minor: 0
patch: 3
patch: 4
AssemblyVersion: $(major).$(minor).$(patch)
NugetVersion: $(major).$(minor).$(patch)-beta

Expand Down
4 changes: 2 additions & 2 deletions src/Console/Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

<ItemGroup>
<PackageReference Include="apache.log4net.Extensions.Logging" Version="2.0.0.12" />
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="log4net" Version="3.0.2" />
<PackageReference Include="Microsoft.NETCore.Platforms" Version="7.0.4" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Terminal.Gui" Version="1.16.0" />
<PackageReference Include="Terminal.Gui" Version="1.17.1" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 4 additions & 8 deletions src/Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace Console;

internal static class Program
{
private static ILogger<ControlPanel> _panelLogger;
private static ControlPanel _controlPanel;
private static readonly Queue<string> Messages = new ();
private static readonly object MessageLock = new ();
Expand Down Expand Up @@ -58,17 +57,16 @@ internal static class Program
private static async Task Main()
{
XmlConfigurator.Configure(
LogManager.GetRepository(Assembly.GetAssembly(typeof(LogManager))),
LogManager.GetRepository(Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly()),
new FileInfo("log4net.config"));

_lastConfigFilePath = Path.Combine(Environment.CurrentDirectory, "appsettings.config");
_lastOsdpConfigFilePath = Environment.CurrentDirectory;

var factory = new LoggerFactory();
factory.AddLog4Net();
_panelLogger = factory.CreateLogger<ControlPanel>();

_controlPanel = new ControlPanel(_panelLogger);
_controlPanel = new ControlPanel(factory);

_settings = GetConnectionSettings();

Expand Down Expand Up @@ -96,10 +94,8 @@ private static async Task Main()
new MenuItem("_Quit", "", () =>
{
SaveConfigurationSettings(_settings);

Application.RequestStop();

Environment.Exit(Environment.ExitCode);

Application.Shutdown();
})
}),
new MenuBarItem("Co_nnections", new[]
Expand Down
21 changes: 11 additions & 10 deletions src/OSDP.Net.Tests/ControlPanelTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging.Abstractions;
using Moq;
using NUnit.Framework;
using OSDP.Net.Connections;
Expand All @@ -24,7 +25,7 @@ public async Task DeviceGoesOnlineTest()
// Arrange
var mockConnection = new MockConnection();

var panel = new ControlPanel();
var panel = new ControlPanel(NullLoggerFactory.Instance);
Guid id = panel.StartConnection(mockConnection.Object);
panel.AddDevice(id, 0, true, false);

Expand All @@ -40,7 +41,7 @@ public async Task ShutdownTest()
// Arrange
var mockConnection = new MockConnection();

var panel = new ControlPanel();
var panel = new ControlPanel(NullLoggerFactory.Instance);
Guid id = panel.StartConnection(mockConnection.Object);
panel.AddDevice(id, 0, true, false);

Expand All @@ -59,7 +60,7 @@ public async Task StartConnectionTest()
{
// Arrange
var mockConnection = new MockConnection();
var panel = new ControlPanel();
var panel = new ControlPanel(NullLoggerFactory.Instance);

// Act
Guid id = panel.StartConnection(mockConnection.Object);
Expand All @@ -75,7 +76,7 @@ public void StartConnectionWithSameConnectionTwiceTest()
{
// Arrange
var mockConnection = new MockConnection();
var panel = new ControlPanel();
var panel = new ControlPanel(NullLoggerFactory.Instance);
var id = panel.StartConnection(mockConnection.Object);

// Act/Assert
Expand All @@ -91,7 +92,7 @@ public void StartSameConnectionConcurrentlyShouldOnlyStartItOnce()
// Arrange
var mockConnection = new MockConnection();
var instance = mockConnection.Object;
var panel = new ControlPanel();
var panel = new ControlPanel(NullLoggerFactory.Instance);

// Act
var tasks = Enumerable
Expand All @@ -115,7 +116,7 @@ public void StopSameConnectionConcurrentlyShouldSucceed()
{
// Arrange
var mockConnection = new MockConnection();
var panel = new ControlPanel();
var panel = new ControlPanel(NullLoggerFactory.Instance);
var id = panel.StartConnection(mockConnection.Object);

// Act
Expand All @@ -139,7 +140,7 @@ public async Task StartConnectionRestartWithSameConnectionTest()
{
// Arrange
var mockConnection = new MockConnection();
var panel = new ControlPanel();
var panel = new ControlPanel(NullLoggerFactory.Instance);

// Act
var id1 = panel.StartConnection(mockConnection.Object);
Expand All @@ -157,7 +158,7 @@ public async Task StopConnectionTest()
{
// Arrange
var mockConnection = new MockConnection();
var panel = new ControlPanel();
var panel = new ControlPanel(NullLoggerFactory.Instance);

Guid id = panel.StartConnection(mockConnection.Object);
panel.AddDevice(id, 0, true, false);
Expand All @@ -178,7 +179,7 @@ public class IdRequestCommandTest
[Test]
public async Task ReturnsValidReportTest()
{
var panel = new ControlPanel(GlobalSetup.CreateLogger<ControlPanel>());
var panel = new ControlPanel(NullLoggerFactory.Instance);
var idReportCommand = new IdReport();
var deviceIdentificationReply =
new DeviceIdentification([0x5C, 0x26, 0x23], 0x19, 0x02, 719912960, 0x03, 0x00, 0x00);
Expand All @@ -203,7 +204,7 @@ public async Task ReturnsValidReportTest()
[Test]
public void ThrowOnNakReplyTest()
{
var panel = new ControlPanel(GlobalSetup.CreateLogger<ControlPanel>());
var panel = new ControlPanel(NullLoggerFactory.Instance);
var idReportCommand = new IdReport();
var nakReply = new Nak(ErrorCode.UnknownCommandCode);

Expand Down
23 changes: 0 additions & 23 deletions src/OSDP.Net.Tests/Global.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/OSDP.Net.Tests/IntegrationTests/PeripheryDeviceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace OSDP.Net.Tests.IntegrationTests;


//
// NOTE: Majority of naming/structure in this file is very much a work-in-progress
// and will be updated if we continue to build out a set of integration tests
Expand Down
6 changes: 3 additions & 3 deletions src/OSDP.Net.Tests/OSDP.Net.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

<ItemGroup>
<PackageReference Include="apache.log4net.Extensions.Logging" Version="2.0.0.12" />
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="log4net" Version="3.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
<PackageReference Include="Microsoft.NETCore.Platforms" Version="7.0.4" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="nunit" Version="3.13.3" />
Expand Down
1 change: 1 addition & 0 deletions src/OSDP.Net/Bus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using OSDP.Net.Model.CommandData;
using OSDP.Net.Model.ReplyData;
using OSDP.Net.Tracing;

#if NETSTANDARD2_0
using OSDP.Net.Utilities;
#endif
Expand Down
24 changes: 23 additions & 1 deletion src/OSDP.Net/ControlPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using OSDP.Net.Connections;
using OSDP.Net.Messages;
using OSDP.Net.Model.CommandData;
Expand Down Expand Up @@ -37,11 +38,32 @@ public class ControlPanel

/// <summary>Initializes a new instance of the <see cref="T:OSDP.Net.ControlPanel" /> class.</summary>
/// <param name="logger">The logger definition used for logging.</param>
[Obsolete("Sending a ILogger is deprecated, please send ILoggerFactory instead.")]
public ControlPanel(ILogger<ControlPanel> logger = null) : this(null, logger) { }

/// <summary>Initializes a new instance of the <see cref="T:OSDP.Net.ControlPanel" /> class.</summary>
/// <param name="loggerFactory">The logger factory used to create logging facilities.</param>
public ControlPanel(ILoggerFactory loggerFactory = null) : this(null, loggerFactory) { }

internal ControlPanel(IDeviceProxyFactory deviceProxyFactory, ILogger<ControlPanel> logger = null)
{
_logger = logger;
_logger = logger ?? NullLoggerFactory.Instance.CreateLogger<ControlPanel>();
_deviceProxyFactory = deviceProxyFactory ?? new DeviceProxyFactory();

Task.Factory.StartNew(() =>
{
foreach (var reply in _replies.GetConsumingEnumerable())
{
OnReplyReceived(reply);
}
}, TaskCreationOptions.LongRunning);
}

internal ControlPanel(IDeviceProxyFactory deviceProxyFactory, ILoggerFactory loggerFactory = null)
{
_logger = loggerFactory != null
? loggerFactory.CreateLogger<ControlPanel>()
: NullLoggerFactory.Instance.CreateLogger<ControlPanel>();
_deviceProxyFactory = deviceProxyFactory ?? new DeviceProxyFactory();

Task.Factory.StartNew(() =>
Expand Down
11 changes: 7 additions & 4 deletions src/OSDP.Net/OSDP.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@
<None Include="Images\icon.png" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="System.Collections" Version="4.3.0" />
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions src/samples/CardReader/CardReader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/samples/PivDataReader/PivDataReader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/samples/PivDataReader/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging.Abstractions;
using OSDP.Net;
using OSDP.Net.Connections;
using OSDP.Net.Model.CommandData;
Expand Down Expand Up @@ -30,7 +31,7 @@ private static async Task Main()
byte elementId = Convert.FromHexString(pivDataSection["ElementId"]!)[0];
ushort offset = ushort.Parse(pivDataSection["Offset"]!);

var panel = new ControlPanel();
var panel = new ControlPanel(NullLoggerFactory.Instance);
panel.ConnectionStatusChanged += async (_, eventArgs) =>
{
Console.WriteLine();
Expand Down