Restructure aadp

This commit is contained in:
Martijn Scheepers
2025-08-13 15:13:22 +02:00
parent d8cfcff79f
commit 5961276657
206 changed files with 5654 additions and 5141 deletions

View File

@@ -1,4 +1,5 @@
using Aperio_Control_Centre.ACSDatabase.Models;
using Aperio_Control_Centre.Aadp.Enumerations;
using Aperio_Control_Centre.ACSDatabase.Models;
using Microsoft.EntityFrameworkCore;
using Moq;
@@ -33,7 +34,7 @@ namespace Aperio_Control_Centre.ACSDatabase.UnitTest
Name = "TestDevice",
Active = Types.ActiveStates.Active,
ConnectionState = Types.ConnectionStates.Offline,
ProductClass = Aadp.Enumerations.ProductClass.LOCK,
ProductClass = ProductClass.LOCK,
Ipaddress = "[::ffff:X.X.X.X]:XXXX",
HubId = "XXXX"
});
@@ -53,11 +54,11 @@ namespace Aperio_Control_Centre.ACSDatabase.UnitTest
Name = "TestHost 1",
Active = Types.ActiveStates.Active,
ConnectionState = Types.ConnectionStates.Online,
ProductClass = Aadp.Enumerations.ProductClass.GATEWAY,
LockState = Aadp.Enumerations.LockState.JAMMED,
HandleState = Aadp.Enumerations.HandleState.INSIDE_USED,
KeyCylinderState = Aadp.Enumerations.KeyCylinderState.USED_POS_2,
TamperState = Aadp.Enumerations.TamperState.TAMPER,
ProductClass = ProductClass.GATEWAY,
LockState = LockState.JAMMED,
HandleState = HandleState.INSIDE_USED,
KeyCylinderState = KeyCylinderState.USED_POS_2,
TamperState = TamperState.TAMPER,
BatteryState = Types.BatteryStates.Flat,
Ipaddress = "[::ffff:192.168.0.42]:49494",
Location = location
@@ -68,7 +69,7 @@ namespace Aperio_Control_Centre.ACSDatabase.UnitTest
Name = "TestHost 2",
Active = Types.ActiveStates.Active,
ConnectionState = Types.ConnectionStates.Offline,
ProductClass = Aadp.Enumerations.ProductClass.GATEWAY,
ProductClass = ProductClass.GATEWAY,
Ipaddress = "[::ffff:X.X.X.X]:XXXX",
LocationId = 2
});
@@ -713,7 +714,7 @@ namespace Aperio_Control_Centre.ACSDatabase.UnitTest
Assert.AreEqual("[::ffff:192.168.0.42]:49494", disabledDevice.Ipaddress);
Assert.AreEqual("TestHost 1", disabledDevice.Name);
Assert.IsNull(disabledDevice.Info);
Assert.AreEqual(Aadp.Enumerations.ProductClass.GATEWAY, disabledDevice.ProductClass);
Assert.AreEqual(ProductClass.GATEWAY, disabledDevice.ProductClass);
Assert.IsNull(disabledDevice.DoorState);
//Assert.IsNull(disabledDevice.LockState);
@@ -829,7 +830,7 @@ namespace Aperio_Control_Centre.ACSDatabase.UnitTest
Device? device = db.Devices.Find(2);
Assert.IsNotNull(device);
device.DoorState = Aadp.Enumerations.DoorState.CLOSED;
device.DoorState = DoorState.CLOSED;
//device.UpdateDeviceState(Aadp.Enumerations.DoorState.CLOSED);
//device.UpdateDeviceState(Aadp.Enumerations.LockState.JAMMED);
//device.UpdateDeviceState(Aadp.Enumerations.HandleState.INSIDE_USED);
@@ -848,12 +849,12 @@ namespace Aperio_Control_Centre.ACSDatabase.UnitTest
Assert.AreEqual("[::ffff:192.168.0.42]:49494", stateDevice.Ipaddress);
Assert.AreEqual("TestHost 1", stateDevice.Name);
Assert.IsNull(stateDevice.Info);
Assert.AreEqual(Aadp.Enumerations.ProductClass.GATEWAY, stateDevice.ProductClass);
Assert.AreEqual(Aadp.Enumerations.DoorState.CLOSED, stateDevice.DoorState);
Assert.AreEqual(Aadp.Enumerations.LockState.JAMMED, stateDevice.LockState);
Assert.AreEqual(Aadp.Enumerations.HandleState.INSIDE_USED, stateDevice.HandleState);
Assert.AreEqual(Aadp.Enumerations.KeyCylinderState.USED_POS_2, stateDevice.KeyCylinderState);
Assert.AreEqual(Aadp.Enumerations.TamperState.TAMPER, stateDevice.TamperState);
Assert.AreEqual(ProductClass.GATEWAY, stateDevice.ProductClass);
Assert.AreEqual(DoorState.CLOSED, stateDevice.DoorState);
Assert.AreEqual(LockState.JAMMED, stateDevice.LockState);
Assert.AreEqual(HandleState.INSIDE_USED, stateDevice.HandleState);
Assert.AreEqual(KeyCylinderState.USED_POS_2, stateDevice.KeyCylinderState);
Assert.AreEqual(TamperState.TAMPER, stateDevice.TamperState);
Assert.AreEqual(Types.BatteryStates.Flat, stateDevice.BatteryState);
Assert.AreEqual(Types.ConnectionStates.Online, stateDevice.ConnectionState);
Assert.IsNull(stateDevice.UnlockTime);

View File

@@ -1,5 +1,5 @@
using Aperio_Control_Centre.ACSDatabase.Models;
using static Aperio_Control_Centre.Aadp.Enumerations;
using Aperio_Control_Centre.Aadp.Enumerations;
using Aperio_Control_Centre.ACSDatabase.Models;
namespace Aperio_Control_Centre.ACSDatabase.UnitTest
{

View File

@@ -3,8 +3,8 @@ using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Aperio_Control_Centre.ACSDatabase.Types;
using Aperio_Control_Centre.Aadp;
using System.ComponentModel;
using Aperio_Control_Centre.Aadp.Enumerations;
namespace Aperio_Control_Centre.ACSDatabase.Models
{
@@ -44,31 +44,31 @@ namespace Aperio_Control_Centre.ACSDatabase.Models
public SupportedDoorModes? DoorModes { get; set; }
[Display(Name = nameof(ProductClass))]
public Aadp.Enumerations.ProductClass? ProductClass { get; set; }
public ProductClass? ProductClass { get; set; }
[Display(Name = nameof(DoorState))]
public Aadp.Enumerations.DoorState? DoorState { get; set; }
public DoorState? DoorState { get; set; }
[Display(Name = nameof(LockState))]
public Aadp.Enumerations.LockState? LockState { get; set; }
public LockState? LockState { get; set; }
[Display(Name = nameof(HandleState))]
public Aadp.Enumerations.HandleState? HandleState { get; set; }
public HandleState? HandleState { get; set; }
[Display(Name = nameof(KeyCylinderState))]
public Aadp.Enumerations.KeyCylinderState? KeyCylinderState { get; set; }
public KeyCylinderState? KeyCylinderState { get; set; }
[Display(Name = nameof(TamperState))]
public Aadp.Enumerations.TamperState? TamperState { get; set; }
public TamperState? TamperState { get; set; }
[Display(Name = nameof(BatteryState))]
public Types.BatteryStates? BatteryState { get; set; }
[Display(Name = nameof(EmergencyInsideState))]
public Enumerations.ActivatorState? EmergencyInsideState { get; set; }
public ActivatorState? EmergencyInsideState { get; set; }
[Display(Name = nameof(EmergencyOutsideState))]
public Enumerations.ActivatorState? EmergencyOutsideState { get; set; }
public ActivatorState? EmergencyOutsideState { get; set; }
[Display(Name = nameof(ConnectionState))]
public Types.ConnectionStates? ConnectionState { get; set; }

View File

@@ -1,12 +1,8 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.ApplicationTypes;
using Aperio_Control_Centre.Aadp.Enumerations;
using Aperio_Control_Centre.ACSDatabase.Models.Extensions;
using Aperio_Control_Centre.ACSDatabase.Types;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq.Expressions;
using System.Net;
using System.Security.Principal;
namespace Aperio_Control_Centre.ACSDatabase.Models
@@ -45,7 +41,7 @@ namespace Aperio_Control_Centre.ACSDatabase.Models
{
return devices
.Where(a => a.Active != ActiveStates.Deleted)
.Where(p => p.ProductClass == Aadp.Enumerations.ProductClass.H1502R11 || p.ProductClass == Aadp.Enumerations.ProductClass.LOCK || p.ProductClass == Aadp.Enumerations.ProductClass.OPTA_V1)
.Where(p => p.ProductClass == ProductClass.H1502R11 || p.ProductClass == ProductClass.LOCK || p.ProductClass == ProductClass.OPTA_V1)
.Include(l => l.Location)
.Select(s => new SelectListItem
{

View File

@@ -1,9 +1,8 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.Enumerations;
using Aperio_Control_Centre.ACSDatabase.Types;
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;
using System.Security.Principal;
using static Aperio_Control_Centre.Aadp.Enumerations;
namespace Aperio_Control_Centre.ACSDatabase.Models.Extensions
{
@@ -39,7 +38,7 @@ namespace Aperio_Control_Centre.ACSDatabase.Models.Extensions
await loggings.AddLogAsync(device, "Batterij leeg", token);
}
break;
case Enumerations.LockState:
case LockState:
switch (state)
{
@@ -57,16 +56,16 @@ namespace Aperio_Control_Centre.ACSDatabase.Models.Extensions
break;
}
break;
case Enumerations.DoorState:
case DoorState:
await loggings.AddLogAsync(device, $"Doorstate ({state})", token);
break;
case Enumerations.KeyCylinderState:
case KeyCylinderState:
await loggings.AddLogAsync(device, $"KeyCylinderState ({state})", token);
break;
case Enumerations.HandleState:
case HandleState:
await loggings.AddLogAsync(device, $"HandleState ({state})", token);
break;
case Enumerations.TamperState:
case TamperState:
switch (state)
{
case TamperState.UNKNOWN:
@@ -82,13 +81,13 @@ namespace Aperio_Control_Centre.ACSDatabase.Models.Extensions
break;
}
break;
case Enumerations.DoorMode:
case DoorMode:
await loggings.AddLogAsync(device, $"DoorMode ({state})", token);
break;
case Enumerations.ProductClass:
case ProductClass:
await loggings.AddLogAsync(device, $"ProductClass ({state})", token);
break;
case Enumerations.Status:
case Status:
await loggings.AddLogAsync(device, $"device Status ({state})", token);
break;

View File

@@ -1,11 +1,10 @@
using Aperio_Control_Centre.Aadp;
using static Aperio_Control_Centre.Aadp.Enumerations;
using Aperio_Control_Centre.Aadp.Enumerations;
namespace Aperio_Control_Centre.ACSDatabase.Models
{
public class SupportedDoorMode
{
public Enumerations.DoorMode DoorMode { get; set; }
public DoorMode DoorMode { get; set; }
public bool CurrentMode { get; set; }
}
@@ -31,7 +30,7 @@ namespace Aperio_Control_Centre.ACSDatabase.Models
}
}
public Enumerations.DoorMode GetDoorMode()
public DoorMode GetDoorMode()
{
if (Count == 0)
{
@@ -40,7 +39,7 @@ namespace Aperio_Control_Centre.ACSDatabase.Models
return this.Where(c => c.CurrentMode == true).Select(m => m.DoorMode).FirstOrDefault();
}
public void SetDoorMode(Enumerations.DoorMode doorMode)
public void SetDoorMode(DoorMode doorMode)
{
foreach (SupportedDoorMode doormode in this)
{

View File

@@ -1,4 +1,5 @@
using BenchmarkDotNet.Attributes;
using Aperio_Control_Centre.Aadp.Commands;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
namespace Aperio_Control_Centre.Aadp.Benchmark

View File

@@ -1,4 +1,10 @@
using BenchmarkDotNet.Attributes;
using Aperio_Control_Centre.Aadp.Commands.Configuration;
using Aperio_Control_Centre.Aadp.Commands.InputFromUser;
using Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance;
using Aperio_Control_Centre.Aadp.Commands.OutputToUser;
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
namespace Aperio_Control_Centre.Aadp.Benchmark
@@ -22,7 +28,7 @@ namespace Aperio_Control_Centre.Aadp.Benchmark
public void Setup()
{
hellorequest = new HelloRequest(2, 48, 23);
helloresponse = new HelloResponse(new ApplicationTypes.Version(18, 42, 0), new VariableLengthQuantity(100));
helloresponse = new HelloResponse(new Types.ApplicationTypes.Version(18, 42, 0), new VariableLengthQuantity(100));
statusrequest = new StatusRequest(Enumerations.Status.UNAVAILABLE);
statusresponse = new StatusResponse(Enumerations.Status.FAIL_PERMISSION);
@@ -36,13 +42,13 @@ namespace Aperio_Control_Centre.Aadp.Benchmark
//},
//};
credentialnotification = new CredentialNotification("0412F5", Enumerations.DoorSide.BOTH, [
new ApplicationTypes.CredentialBlock(Enumerations.CredentialBlockType.MIFAREUID, [0x0A, 0x1B, 0x2C, 0x3D]),
new ApplicationTypes.CredentialBlock(Enumerations.CredentialBlockType.ISO14443BUID, [0x11, 0x22, 0x33, 0x44, 0x55])
new CredentialBlock(Enumerations.CredentialBlockType.MIFAREUID, [0x0A, 0x1B, 0x2C, 0x3D]),
new CredentialBlock(Enumerations.CredentialBlockType.ISO14443BUID, [0x11, 0x22, 0x33, 0x44, 0x55])
]);
keypadnotification = new KeypadNotification
{
DeviceGroupId = new ApplicationTypes.Id("0412F5"),
DeviceGroupId = new Id("0412F5"),
DoorSide = Enumerations.DoorSide.BOTH,
Keys = "5432"
};

View File

@@ -1,4 +1,11 @@
using BenchmarkDotNet.Attributes;
using Aperio_Control_Centre.Aadp.Commands;
using Aperio_Control_Centre.Aadp.Commands.Configuration;
using Aperio_Control_Centre.Aadp.Commands.InputFromUser;
using Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance;
using Aperio_Control_Centre.Aadp.Commands.OutputToUser;
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
namespace Aperio_Control_Centre.Aadp.Benchmark
@@ -22,7 +29,7 @@ namespace Aperio_Control_Centre.Aadp.Benchmark
public void Setup()
{
hellorequest = new HelloRequest(2, 48, 23);
helloresponse = new HelloResponse(new ApplicationTypes.Version(18, 42, 0), new VariableLengthQuantity(100));
helloresponse = new HelloResponse(new Types.ApplicationTypes.Version(18, 42, 0), new VariableLengthQuantity(100));
statusrequest = new StatusRequest(Enumerations.Status.UNAVAILABLE);
statusresponse = new StatusResponse(Enumerations.Status.FAIL_PERMISSION);
@@ -36,13 +43,13 @@ namespace Aperio_Control_Centre.Aadp.Benchmark
//},
//};
credentialnotification = new CredentialNotification("0412F5", Enumerations.DoorSide.BOTH, [
new ApplicationTypes.CredentialBlock(Enumerations.CredentialBlockType.MIFAREUID, [0x0A, 0x1B, 0x2C, 0x3D]),
new ApplicationTypes.CredentialBlock(Enumerations.CredentialBlockType.ISO14443BUID, [0x11, 0x22, 0x33, 0x44, 0x55])
new CredentialBlock(Enumerations.CredentialBlockType.MIFAREUID, [0x0A, 0x1B, 0x2C, 0x3D]),
new CredentialBlock(Enumerations.CredentialBlockType.ISO14443BUID, [0x11, 0x22, 0x33, 0x44, 0x55])
]);
keypadnotification = new KeypadNotification
{
DeviceGroupId = new ApplicationTypes.Id("0412F5"),
DeviceGroupId = new Id("0412F5"),
DoorSide = Enumerations.DoorSide.BOTH,
Keys = "5432"
};

View File

@@ -1,4 +1,6 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.Commands;
using Aperio_Control_Centre.Aadp.Commands.DeviceStates;
using Aperio_Control_Centre.Aadp.Types;
namespace Aperio_Control_Centre.Aadp.UnitTest
{

View File

@@ -1,5 +1,5 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.ApplicationTypes;
using Aperio_Control_Centre.Aadp.Enumerations;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.UnitTest
@@ -12,7 +12,7 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
public void Version_Tests()
{
//Aperio_Control_Centre.Aadp.Version version1 = new Version(5, 255, 128);
ApplicationTypes.Version version = new(5, 255, 128);
Types.ApplicationTypes.Version version = new(5, 255, 128);
List<byte> bytes = [];
version.Serialize(ref bytes);
CollectionAssert.AreEqual(new byte[] { 0x05, 0x81, 0x7F, 0x81, 0x00 }, bytes);
@@ -23,7 +23,7 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
byte[] arr = [0x00, 0x04, 0x01, 0x01, 0x04, 0x00];
int idx = 3;
version = new ApplicationTypes.Version(ref arr, ref idx);
version = new Types.ApplicationTypes.Version(ref arr, ref idx);
Assert.AreEqual(6, idx);
sb = new StringBuilder();
@@ -38,7 +38,7 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
{
byte[] arr = [0x01];
int idx = 0;
ApplicationTypes.Version version = new(ref arr, ref idx);
Types.ApplicationTypes.Version version = new(ref arr, ref idx);
StringBuilder sb = new();
version.LogString(ref sb);

View File

@@ -1,4 +1,6 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.Commands;
using Aperio_Control_Centre.Aadp.Commands.Configuration;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.UnitTest
@@ -100,7 +102,7 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
[TestMethod]
public void HelloResponse_Version()
{
IPduCommand command = new HelloResponse(new ApplicationTypes.Version(18, 42, 0), new VariableLengthQuantity(100));
IPduCommand command = new HelloResponse(new Types.ApplicationTypes.Version(18, 42, 0), new VariableLengthQuantity(100));
Assert.AreEqual("HelloResponse", command.ToString());
Assert.AreEqual("Version-'18.42.0' Pinginterval-'100'", command.LogString());
@@ -148,7 +150,7 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
IPduCommand command = new DeviceGroupInfoNotification
{
Type = Enumerations.DeviceGroupInfoNotificationType.ADDED,
Info = new ApplicationTypes.DeviceGroupInfo(new ApplicationTypes.Id("ABCDE"), "Name", "Location")
Info = new DeviceGroupInfo(new Id("ABCDE"), "Name", "Location")
};
Assert.AreEqual("DeviceGroupInfoNotification", command.ToString());
Assert.AreEqual(" Device-'ABCDE' Name-'Name' Location-'Location' Type-'ADDED'", command.LogString());
@@ -182,10 +184,10 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
[TestMethod]
public void SetDeviceParameterCommand_Parameters_Uintvar()
{
List<ApplicationTypes.SetDeviceParameterCommandBlock> commandBlocks =
List<SetDeviceParameterCommandBlock> commandBlocks =
[
new ApplicationTypes.SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.UINTVAR, "test", new VariableLengthQuantity(99)),
new ApplicationTypes.SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.UINTVAR, "test1", new VariableLengthQuantity(12))
new SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.UINTVAR, "test", new VariableLengthQuantity(99)),
new SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.UINTVAR, "test1", new VariableLengthQuantity(12))
];
//IPduCommand command = new SetDeviceParameterCommand
@@ -220,10 +222,10 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
[TestMethod]
public void SetDeviceParameterCommand_Parameters_Boolean()
{
List<ApplicationTypes.SetDeviceParameterCommandBlock> commandBlocks =
List<SetDeviceParameterCommandBlock> commandBlocks =
[
new ApplicationTypes.SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.BOOLEAN, "test", true),
new ApplicationTypes.SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.BOOLEAN, "test1", false)
new SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.BOOLEAN, "test", true),
new SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.BOOLEAN, "test1", false)
];
//IPduCommand command = new SetDeviceParameterCommand
@@ -257,10 +259,10 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
[TestMethod]
public void SetDeviceParameterCommand_Parameters_String()
{
List<ApplicationTypes.SetDeviceParameterCommandBlock> commandBlocks =
List<SetDeviceParameterCommandBlock> commandBlocks =
[
new ApplicationTypes.SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.STRING, "test", "eerste"),
new ApplicationTypes.SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.STRING, "test1", "tweede")
new SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.STRING, "test", "eerste"),
new SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.STRING, "test1", "tweede")
];
//IPduCommand command = new SetDeviceParameterCommand
@@ -294,10 +296,10 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
[TestMethod]
public void SetDeviceParameterCommand_Parameters_Short()
{
List<ApplicationTypes.SetDeviceParameterCommandBlock> commandBlocks =
List<SetDeviceParameterCommandBlock> commandBlocks =
[
new ApplicationTypes.SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.SHORT, "test", 1),
new ApplicationTypes.SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.SHORT, "test1", 42)
new SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.SHORT, "test", 1),
new SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.SHORT, "test1", 42)
];
//IPduCommand command = new SetDeviceParameterCommand
@@ -331,10 +333,10 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
[TestMethod]
public void SetDeviceParameterCommand_Parameters_ByteArray()
{
List<ApplicationTypes.SetDeviceParameterCommandBlock> commandBlocks =
List<SetDeviceParameterCommandBlock> commandBlocks =
[
new ApplicationTypes.SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.BYTE_ARRAY, "test", new byte[] { 0x01, 0x02, 0x03, 0x04 }),
new ApplicationTypes.SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.BYTE_ARRAY, "test1", new byte[] { 0xDE, 0xAD, 0xBE, 0xEF })
new SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.BYTE_ARRAY, "test", new byte[] { 0x01, 0x02, 0x03, 0x04 }),
new SetDeviceParameterCommandBlock(Enumerations.DeviceParameterType.BYTE_ARRAY, "test1", new byte[] { 0xDE, 0xAD, 0xBE, 0xEF })
];
//IPduCommand command = new SetDeviceParameterCommand
@@ -512,11 +514,11 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
[TestMethod]
public void SetDeviceParameterResult_Parameter()
{
List<ApplicationTypes.SetDeviceParameterResultBlock> resultBlocks =
List<SetDeviceParameterResultBlock> resultBlocks =
[
new ApplicationTypes.SetDeviceParameterResultBlock("para1", Enumerations.Status.OK),
new ApplicationTypes.SetDeviceParameterResultBlock("parameter2", Enumerations.Status.FAIL),
new ApplicationTypes.SetDeviceParameterResultBlock("billy", Enumerations.Status.UNAVAILABLE)
new SetDeviceParameterResultBlock("para1", Enumerations.Status.OK),
new SetDeviceParameterResultBlock("parameter2", Enumerations.Status.FAIL),
new SetDeviceParameterResultBlock("billy", Enumerations.Status.UNAVAILABLE)
];
IPduCommand command = new SetDeviceParameterResult("0412F5", resultBlocks);
@@ -577,11 +579,11 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
//TODO: DeviceParameterNotification UnitTest
public void DeviceParameterNotification_Parameter()
{
List<ApplicationTypes.SetDeviceParameterResultBlock> resultBlocks =
List<SetDeviceParameterResultBlock> resultBlocks =
[
new ApplicationTypes.SetDeviceParameterResultBlock("para1", Enumerations.Status.OK),
new ApplicationTypes.SetDeviceParameterResultBlock("parameter2", Enumerations.Status.FAIL),
new ApplicationTypes.SetDeviceParameterResultBlock("billy", Enumerations.Status.UNAVAILABLE)
new SetDeviceParameterResultBlock("para1", Enumerations.Status.OK),
new SetDeviceParameterResultBlock("parameter2", Enumerations.Status.FAIL),
new SetDeviceParameterResultBlock("billy", Enumerations.Status.UNAVAILABLE)
];
IPduCommand command = new SetDeviceParameterResult("0412F5", resultBlocks);
@@ -694,13 +696,13 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
[TestMethod]
public void GetDeviceParameterCommand_Parameter()
{
List<ApplicationTypes.DeviceParameterName> deviceParameters =
List<DeviceParameterName> deviceParameters =
[
new ApplicationTypes.DeviceParameterName("billy"),
new ApplicationTypes.DeviceParameterName("test")
new DeviceParameterName("billy"),
new DeviceParameterName("test")
];
IPduCommand command = new GetDeviceParameterCommand(new ApplicationTypes.DeviceId("0412F5"), deviceParameters);
IPduCommand command = new GetDeviceParameterCommand(new DeviceId("0412F5"), deviceParameters);
Assert.AreEqual("GetDeviceParameterCommand", command.ToString());
Assert.AreEqual(" DeviceId-'00 17 7A 01 02 04 12 F5 00 00 00 00' Parameter-'billy'" + Environment.NewLine + " Parameter-'test'" + Environment.NewLine, command.LogString());
@@ -921,11 +923,11 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
[TestMethod]
public void GetDeviceParameterResult_Parameter()
{
List<ApplicationTypes.DeviceParameterNotificationBlock> deviceParameters =
List<DeviceParameterNotificationBlock> deviceParameters =
[
new ApplicationTypes.DeviceParameterNotificationBlock("bool", true, Enumerations.Status.OK),
new ApplicationTypes.DeviceParameterNotificationBlock("billy", "bob", Enumerations.Status.FAIL_UNKNOWN_ID),
new ApplicationTypes.DeviceParameterNotificationBlock("test", -42, Enumerations.Status.OK)
new DeviceParameterNotificationBlock("bool", true, Enumerations.Status.OK),
new DeviceParameterNotificationBlock("billy", "bob", Enumerations.Status.FAIL_UNKNOWN_ID),
new DeviceParameterNotificationBlock("test", -42, Enumerations.Status.OK)
];
IPduCommand command = new GetDeviceParameterResult("0412F5", deviceParameters);

View File

@@ -1,4 +1,6 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.Commands;
using Aperio_Control_Centre.Aadp.Commands.DeviceStates;
using Aperio_Control_Centre.Aadp.Types;
namespace Aperio_Control_Centre.Aadp.UnitTest
{

View File

@@ -1,4 +1,6 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.Commands;
using Aperio_Control_Centre.Aadp.Commands.DoorControl;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.UnitTest
@@ -426,10 +428,10 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
[TestMethod]
public void SetCredentialCommand_Parameters()
{
List<ApplicationTypes.CredentialBlock> credentials =
List<CredentialBlock> credentials =
[
new ApplicationTypes.CredentialBlock(Enumerations.CredentialBlockType.MIFAREUID, [0xFA, 0xCE, 0xDE, 0xAD]),
new ApplicationTypes.CredentialBlock(Enumerations.CredentialBlockType.DynamicData, [0xDE, 0xAD, 0xBE, 0xEF])
new CredentialBlock(Enumerations.CredentialBlockType.MIFAREUID, [0xFA, 0xCE, 0xDE, 0xAD]),
new CredentialBlock(Enumerations.CredentialBlockType.DynamicData, [0xDE, 0xAD, 0xBE, 0xEF])
];
IPduCommand command = new SetCredentialCommand("0412F5", Enumerations.ExpireType.TIME, 128, credentials);
@@ -552,10 +554,10 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
[TestMethod]
public void DeleteCredentialCommand_Parameters()
{
List<ApplicationTypes.CredentialBlock> credentials =
List<CredentialBlock> credentials =
[
new ApplicationTypes.CredentialBlock(Enumerations.CredentialBlockType.MIFAREUID, [0xFA, 0xCE, 0xDE, 0xAD]),
new ApplicationTypes.CredentialBlock(Enumerations.CredentialBlockType.DynamicData, [0xDE, 0xAD, 0xBE, 0xEF])
new CredentialBlock(Enumerations.CredentialBlockType.MIFAREUID, [0xFA, 0xCE, 0xDE, 0xAD]),
new CredentialBlock(Enumerations.CredentialBlockType.DynamicData, [0xDE, 0xAD, 0xBE, 0xEF])
];
IPduCommand command = new DeleteCredentialCommand("0412F5", Enumerations.CredentialDeleteMode.DELETE_SINGLE, credentials);
@@ -588,7 +590,7 @@ namespace Aperio_Control_Centre.Aadp.UnitTest
[TestMethod]
public void DeleteCredentialCommand_Parameters_All()
{
IPduCommand command = new DeleteCredentialCommand(new ApplicationTypes.DeviceId("0412F5"), Enumerations.CredentialDeleteMode.DELETE_ALL_DYNAMIC_AND_STATIC, 42);
IPduCommand command = new DeleteCredentialCommand(new DeviceId("0412F5"), Enumerations.CredentialDeleteMode.DELETE_ALL_DYNAMIC_AND_STATIC, 42);
Assert.AreEqual("DeleteCredentialCommand", command.ToString());

View File

@@ -1,5 +1,6 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.ApplicationTypes;
using Aperio_Control_Centre.Aadp.Commands;
using Aperio_Control_Centre.Aadp.Commands.InputFromUser;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
namespace Aperio_Control_Centre.Aadp.UnitTest
{

View File

@@ -1,5 +1,8 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.ApplicationTypes;
using Aperio_Control_Centre.Aadp.Commands;
using Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance;
using Aperio_Control_Centre.Aadp.Enumerations;
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.UnitTest

View File

@@ -1,4 +1,6 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.Commands;
using Aperio_Control_Centre.Aadp.Commands.OutputToUser;
using Aperio_Control_Centre.Aadp.Types;
namespace Aperio_Control_Centre.Aadp.UnitTest
{

View File

@@ -1,5 +1,5 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.ApplicationTypes;
using Aperio_Control_Centre.Aadp.Enumerations;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.UnitTest

View File

@@ -1,4 +1,6 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.Commands;
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Diagnostics;
namespace Aperio_Control_Centre.Aadp.UnitTest

View File

@@ -1,4 +1,4 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.Commands;
namespace Aperio_Control_Centre.Aadp.UnitTest
{

View File

@@ -1,4 +1,4 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.Types;
using System.Buffers;
namespace Aperio_Control_Centre.Aadp.UnitTest

View File

@@ -1,4 +1,4 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.Types;
namespace Aperio_Control_Centre.Aadp.UnitTest
{

View File

@@ -1,4 +1,4 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.Enumerations;
namespace Aperio_Control_Centre.Aadp.UnitTest
{

View File

@@ -1,4 +1,4 @@
using Aperio_Control_Centre.Aadp;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
namespace Aperio_Control_Centre.Aadp.UnitTest
{

View File

@@ -0,0 +1,9 @@
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
namespace Aperio_Control_Centre.Aadp.Commands
{
public class CommandDeviceIdBase
{
public DeviceId Device { get; set; } = new();
}
}

View File

@@ -1,4 +1,6 @@
namespace Aperio_Control_Centre.Aadp
using Aperio_Control_Centre.Aadp.Types;
namespace Aperio_Control_Centre.Aadp.Commands
{
public class CommandError : IPduCommand
{

View File

@@ -0,0 +1,9 @@
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
namespace Aperio_Control_Centre.Aadp.Commands
{
public class CommandIdBase
{
public Id DeviceGroupId { get; set; } = new();
}
}

View File

@@ -1,471 +0,0 @@
using Aperio_Control_Centre.Aadp.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp
{
public class HelloRequest : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.HelloRequest;
public ApplicationTypes.Version Version { get; set; } = new();
public HelloRequest() { }
public HelloRequest(uint major, uint minor, uint patch)
{
Version = new ApplicationTypes.Version(major, minor, patch);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Version = new ApplicationTypes.Version(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Version.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Version.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class HelloResponse : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.HelloResponse;
public ApplicationTypes.Version Version { get; set; } = new();
public VariableLengthQuantity PingInterval { get; set; } = new();
public HelloResponse() { }
public HelloResponse(ApplicationTypes.Version version, VariableLengthQuantity pinginterval)
{
Version = version;
PingInterval = pinginterval;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Version = new ApplicationTypes.Version(ref arr, ref idx);
PingInterval = new VariableLengthQuantity(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Version.Serialize(ref arr);
PingInterval.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Version.LogString(ref sb);
sb.Append(" Pinginterval-'");
PingInterval.LogString(ref sb);
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class DeviceGroupInfoNotification : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DeviceGroupInfoNotification;
public DeviceGroupInfo Info { get; set; } = new();
public Enumerations.DeviceGroupInfoNotificationType Type { get; set; }
public DeviceGroupInfoNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
Info = new DeviceGroupInfo(ref arr, ref idx);
Type = (Enumerations.DeviceGroupInfoNotificationType)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Info.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Type));
}
public string LogString()
{
StringBuilder sb = new();
Info.LogString(ref sb);
sb.Append(" Type-'");
sb.Append(Type.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
//****************** SET device parameter ***************************************
public class SetDeviceParameterCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.SetDeviceParameterCommand;
public DeviceId Device { get; set; } = new();
public List<SetDeviceParameterCommandBlock> ParameterCommandBlock { get; } = [];
public SetDeviceParameterCommand() { }
public SetDeviceParameterCommand(byte[] id, List<SetDeviceParameterCommandBlock> commandBlocks)
{
Device = new DeviceId(id);
ParameterCommandBlock = commandBlocks;
}
public SetDeviceParameterCommand(string id, List<SetDeviceParameterCommandBlock> commandBlocks)
{
Device = new DeviceId(id);
ParameterCommandBlock = commandBlocks;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
//ParameterCommandBlock = [];
for (int i = 1; i <= arrlen.Value; i++)
{
SetDeviceParameterCommandBlock setDeviceParameterCommandBlock = new(ref arr, ref idx);
ParameterCommandBlock.Add(setDeviceParameterCommandBlock);
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
if (ParameterCommandBlock != null)
{
new VariableLengthQuantity((uint)ParameterCommandBlock.Count).Serialize(ref arr);
foreach (var para in ParameterCommandBlock)
{
para.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
if (ParameterCommandBlock != null)
{
foreach (var par in ParameterCommandBlock)
{
par.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class SetDeviceParameterResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.SetDeviceParameterResult;
public DeviceId Device { get; set; } = new();
public List<SetDeviceParameterResultBlock> ParameterResultBlock { get; } = [];
public SetDeviceParameterResult() { }
public SetDeviceParameterResult(byte[] id, List<SetDeviceParameterResultBlock> resultBlocks)
{
Device = new DeviceId(id);
ParameterResultBlock = resultBlocks;
}
public SetDeviceParameterResult(string id, List<SetDeviceParameterResultBlock> resultBlocks)
{
Device = new DeviceId(id);
ParameterResultBlock = resultBlocks;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
//ParameterResultBlock = [];
for (int i = 1; i <= arrlen.Value; i++)
{
SetDeviceParameterResultBlock setDeviceParameterResultBlock = new(ref arr, ref idx);
ParameterResultBlock.Add(setDeviceParameterResultBlock);
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
if (ParameterResultBlock != null)
{
new VariableLengthQuantity((uint)ParameterResultBlock.Count).Serialize(ref arr);
foreach (var para in ParameterResultBlock)
{
para.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
if (ParameterResultBlock != null)
{
foreach (var par in ParameterResultBlock)
{
par.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
//****************** GET device parameter ***************************************
public class GetDeviceParameterCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetDeviceParameterCommand;
public DeviceId Device { get; set; } = new();
public List<DeviceParameterName> Name { get; } = [];
public GetDeviceParameterCommand() { }
public GetDeviceParameterCommand(byte[] deviceId, List<DeviceParameterName> deviceParameters)
{
Device = new DeviceId(deviceId);
Name = deviceParameters;
}
public GetDeviceParameterCommand(DeviceId deviceId, List<DeviceParameterName> deviceParameters)
{
Device = deviceId;
Name = deviceParameters;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
//Name = [];
int msgLen = arr.Length - idx;
while (msgLen != 0)
{
DeviceParameterName deviceParameterName = new(ref arr, ref idx);
Name.Add(deviceParameterName);
msgLen = arr.Length - idx;
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
if (Name != null)
{
foreach (var name in Name)
{
name.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
if (Name != null)
{
foreach (var name in Name)
{
name.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetDeviceParameterResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetDeviceParameterResult;
public DeviceId Device { get; set; } = new();
public List<DeviceParameterNotificationBlock> ParameterResultBlock { get; } = [];
public GetDeviceParameterResult() { }
public GetDeviceParameterResult(string devId, List<DeviceParameterNotificationBlock> notificationBlocks)
{
Device = new DeviceId(devId);
ParameterResultBlock = notificationBlocks;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
//ParameterResultBlock = [];
int msgLen = arr.Length - idx;
while (msgLen != 0)
{
DeviceParameterNotificationBlock deviceParameterNotificationBlock = new(ref arr, ref idx);
ParameterResultBlock.Add(deviceParameterNotificationBlock);
msgLen = arr.Length - idx;
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
if (ParameterResultBlock != null)
{
foreach (var para in ParameterResultBlock)
{
para.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
if (ParameterResultBlock != null)
{
foreach (var para in ParameterResultBlock)
{
para.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class DeviceParameterNotification : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DeviceParameterNotification;
public DeviceId Device { get; set; } = new();
public List<DeviceParameterNotificationBlock> ParameterNotificationBlock { get; } = [];
public DeviceParameterNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
//ParameterNotificationBlock = [];
for (int i = 1; i <= arrlen.Value; i++)
{
DeviceParameterNotificationBlock deviceParameterNotificationBlock = new(ref arr, ref idx);
ParameterNotificationBlock.Add(deviceParameterNotificationBlock);
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
if (ParameterNotificationBlock != null)
{
foreach (var para in ParameterNotificationBlock)
{
para.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
if (ParameterNotificationBlock != null)
{
foreach (var para in ParameterNotificationBlock)
{
para.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class RestartCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.RestartCommand;
public RestartCommand() { }
public void Deserialize(ref byte[] arr, ref int idx) { }
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
arr.Add(0x07);
}
public string LogString()
{
return "Restart";
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,44 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.Configuration
{
public class DeviceGroupInfoNotification : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DeviceGroupInfoNotification;
public DeviceGroupInfo Info { get; set; } = new();
public Enumerations.DeviceGroupInfoNotificationType Type { get; set; }
public DeviceGroupInfoNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
Info = new DeviceGroupInfo(ref arr, ref idx);
Type = (Enumerations.DeviceGroupInfoNotificationType)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Info.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Type));
}
public string LogString()
{
StringBuilder sb = new();
Info.LogString(ref sb);
sb.Append(" Type-'");
sb.Append(Type.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,60 @@
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.Configuration
{
public class DeviceParameterNotification : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DeviceParameterNotification;
public List<DeviceParameterNotificationBlock> ParameterNotificationBlock { get; } = [];
public DeviceParameterNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
//ParameterNotificationBlock = [];
for (int i = 1; i <= arrlen.Value; i++)
{
DeviceParameterNotificationBlock deviceParameterNotificationBlock = new(ref arr, ref idx);
ParameterNotificationBlock.Add(deviceParameterNotificationBlock);
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
if (ParameterNotificationBlock != null)
{
foreach (var para in ParameterNotificationBlock)
{
para.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
if (ParameterNotificationBlock != null)
{
foreach (var para in ParameterNotificationBlock)
{
para.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,74 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.Configuration
{
//****************** GET device parameter ***************************************
public class GetDeviceParameterCommand : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetDeviceParameterCommand;
public List<DeviceParameterName> Name { get; } = [];
public GetDeviceParameterCommand() { }
public GetDeviceParameterCommand(byte[] deviceId, List<DeviceParameterName> deviceParameters)
{
Device = new DeviceId(deviceId);
Name = deviceParameters;
}
public GetDeviceParameterCommand(DeviceId deviceId, List<DeviceParameterName> deviceParameters)
{
Device = deviceId;
Name = deviceParameters;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
//Name = [];
int msgLen = arr.Length - idx;
while (msgLen != 0)
{
DeviceParameterName deviceParameterName = new(ref arr, ref idx);
Name.Add(deviceParameterName);
msgLen = arr.Length - idx;
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
if (Name != null)
{
foreach (var name in Name)
{
name.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
if (Name != null)
{
foreach (var name in Name)
{
name.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,66 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.Configuration
{
public class GetDeviceParameterResult : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetDeviceParameterResult;
public List<DeviceParameterNotificationBlock> ParameterResultBlock { get; } = [];
public GetDeviceParameterResult() { }
public GetDeviceParameterResult(string devId, List<DeviceParameterNotificationBlock> notificationBlocks)
{
Device = new DeviceId(devId);
ParameterResultBlock = notificationBlocks;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
//ParameterResultBlock = [];
int msgLen = arr.Length - idx;
while (msgLen != 0)
{
DeviceParameterNotificationBlock deviceParameterNotificationBlock = new(ref arr, ref idx);
ParameterResultBlock.Add(deviceParameterNotificationBlock);
msgLen = arr.Length - idx;
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
if (ParameterResultBlock != null)
{
foreach (var para in ParameterResultBlock)
{
para.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
if (ParameterResultBlock != null)
{
foreach (var para in ParameterResultBlock)
{
para.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,43 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.Configuration
{
public class HelloRequest : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.HelloRequest;
public Types.ApplicationTypes.Version Version { get; set; } = new();
public HelloRequest() { }
public HelloRequest(uint major, uint minor, uint patch)
{
Version = new Types.ApplicationTypes.Version(major, minor, patch);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Version = new Types.ApplicationTypes.Version(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Version.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Version.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,48 @@
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.Configuration
{
public class HelloResponse : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.HelloResponse;
public Types.ApplicationTypes.Version Version { get; set; } = new();
public VariableLengthQuantity PingInterval { get; set; } = new();
public HelloResponse() { }
public HelloResponse(Types.ApplicationTypes.Version version, VariableLengthQuantity pinginterval)
{
Version = version;
PingInterval = pinginterval;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Version = new Types.ApplicationTypes.Version(ref arr, ref idx);
PingInterval = new VariableLengthQuantity(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Version.Serialize(ref arr);
PingInterval.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Version.LogString(ref sb);
sb.Append(" Pinginterval-'");
PingInterval.LogString(ref sb);
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,28 @@
namespace Aperio_Control_Centre.Aadp.Commands.Configuration
{
public class RestartCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.RestartCommand;
public RestartCommand() { }
public void Deserialize(ref byte[] arr, ref int idx) { }
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
arr.Add(0x07);
}
public string LogString()
{
return "Restart";
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,73 @@
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.Configuration
{
//****************** SET device parameter ***************************************
public class SetDeviceParameterCommand : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.SetDeviceParameterCommand;
public List<SetDeviceParameterCommandBlock> ParameterCommandBlock { get; } = [];
public SetDeviceParameterCommand() { }
public SetDeviceParameterCommand(byte[] id, List<SetDeviceParameterCommandBlock> commandBlocks)
{
Device = new DeviceId(id);
ParameterCommandBlock = commandBlocks;
}
public SetDeviceParameterCommand(string id, List<SetDeviceParameterCommandBlock> commandBlocks)
{
Device = new DeviceId(id);
ParameterCommandBlock = commandBlocks;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
//ParameterCommandBlock = [];
for (int i = 1; i <= arrlen.Value; i++)
{
SetDeviceParameterCommandBlock setDeviceParameterCommandBlock = new(ref arr, ref idx);
ParameterCommandBlock.Add(setDeviceParameterCommandBlock);
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
if (ParameterCommandBlock != null)
{
new VariableLengthQuantity((uint)ParameterCommandBlock.Count).Serialize(ref arr);
foreach (var para in ParameterCommandBlock)
{
para.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
if (ParameterCommandBlock != null)
{
foreach (var par in ParameterCommandBlock)
{
par.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,72 @@
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.Configuration
{
public class SetDeviceParameterResult : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.SetDeviceParameterResult;
public List<SetDeviceParameterResultBlock> ParameterResultBlock { get; } = [];
public SetDeviceParameterResult() { }
public SetDeviceParameterResult(byte[] id, List<SetDeviceParameterResultBlock> resultBlocks)
{
Device = new DeviceId(id);
ParameterResultBlock = resultBlocks;
}
public SetDeviceParameterResult(string id, List<SetDeviceParameterResultBlock> resultBlocks)
{
Device = new DeviceId(id);
ParameterResultBlock = resultBlocks;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
//ParameterResultBlock = [];
for (int i = 1; i <= arrlen.Value; i++)
{
SetDeviceParameterResultBlock setDeviceParameterResultBlock = new(ref arr, ref idx);
ParameterResultBlock.Add(setDeviceParameterResultBlock);
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
if (ParameterResultBlock != null)
{
new VariableLengthQuantity((uint)ParameterResultBlock.Count).Serialize(ref arr);
foreach (var para in ParameterResultBlock)
{
para.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
if (ParameterResultBlock != null)
{
foreach (var par in ParameterResultBlock)
{
par.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -1,698 +0,0 @@
using Aperio_Control_Centre.Aadp.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp
{
public class GetDoorStateCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetDoorStateCommand;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public GetDoorStateCommand() { }
public GetDoorStateCommand(String deviceGroupId)
{
DeviceGroupId = new ApplicationTypes.Id(deviceGroupId);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class DoorStateResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DoorStateResult;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public Enumerations.DoorState State { get; set; }
public DoorStateResult() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
State = (Enumerations.DoorState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class DoorStateNotification : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DoorStateNotification;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public Enumerations.DoorState State { get; set; }
public DoorStateNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
State = (Enumerations.DoorState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetLockStateCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetLockStateCommand;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public GetLockStateCommand() { }
public GetLockStateCommand(String deviceGroupId)
{
DeviceGroupId = new ApplicationTypes.Id(deviceGroupId);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class LockStateResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.LockStateResult;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public Enumerations.LockState State { get; set; }
public LockStateResult() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
State = (Enumerations.LockState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class LockStateNotification : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.LockStateNotification;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public Enumerations.LockState State { get; set; }
public LockStateNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
State = (Enumerations.LockState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetKeyCylinderStateCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetKeyCylinderStateCommand;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public GetKeyCylinderStateCommand() { }
public GetKeyCylinderStateCommand(String deviceGroupId)
{
DeviceGroupId = new ApplicationTypes.Id(deviceGroupId);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class KeyCylinderStateResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.KeyCylinderStateResult;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public Enumerations.KeyCylinderState State { get; set; }
public KeyCylinderStateResult() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
State = (Enumerations.KeyCylinderState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class KeyCylinderStateNotification : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.KeyCylinderStateNotification;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public Enumerations.KeyCylinderState State { get; set; }
public KeyCylinderStateNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
State = (Enumerations.KeyCylinderState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetHandleStateCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetHandleStateCommand;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public GetHandleStateCommand() { }
public GetHandleStateCommand(String deviceGroupId)
{
DeviceGroupId = new ApplicationTypes.Id(deviceGroupId);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class HandleStateResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.HandleStateResult;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public Enumerations.HandleState State { get; set; }
public HandleStateResult() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
State = (Enumerations.HandleState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class HandleStateNotification : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.HandleStateNotification;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public Enumerations.HandleState State { get; set; }
public HandleStateNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
State = (Enumerations.HandleState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetTamperStateCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetTamperStateCommand;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public GetTamperStateCommand() { }
public GetTamperStateCommand(String deviceGroupId)
{
DeviceGroupId = new ApplicationTypes.Id(deviceGroupId);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class TamperStateResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.TamperStateResult;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public Enumerations.TamperState State { get; set; }
public TamperStateResult() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
State = (Enumerations.TamperState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class TamperStateNotification : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.TamperStateNotification;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public Enumerations.TamperState State { get; set; }
public TamperStateNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
State = (Enumerations.TamperState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetActivatorStateCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetActivatorStateCommand;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public GetActivatorStateCommand() { }
public GetActivatorStateCommand(String deviceGroupId)
{
DeviceGroupId = new ApplicationTypes.Id(deviceGroupId);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class ActivatorStateResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.ActivatorStateResult;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public List<ActivatorInfo> ActivatorInfo { get; } = [];
public ActivatorStateResult() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
VariableLengthQuantity activatorNum = new(ref arr, ref idx);
//ActivatorInfo = [];
for (int i = 1; i <= activatorNum.Value; i++)
{
//ActivatorInfo.Add((Enumerations.ActivatorState)PrimitiveType.DeserializeEnum(ref arr, ref idx));
//ActivatorInfo.Add((Enumerations.ActivatorState)PrimitiveType.DeserializeEnum(ref arr, ref idx));
ActivatorInfo.Add(new(ref arr, ref idx));
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
if (ActivatorInfo != null)
{
new VariableLengthQuantity((uint)ActivatorInfo.Count).Serialize(ref arr);
foreach (var info in ActivatorInfo)
{
//arr.AddRange(PrimitiveType.SerializeEnum((Int16)act));
//arr.AddRange(act.Serialize());
info.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
if (ActivatorInfo != null)
{
foreach (var info in ActivatorInfo)
{
info.LogString(ref sb);
//sb.Append(" State='");
//sb.Append(state.ToString());
//sb.Append('\'');
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class ActivatorStateNotification : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.ActivatorStateNotification;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public ActivatorInfo ActivatorInfo { get; set; } = new();
public ActivatorStateNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
ActivatorInfo = new(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
ActivatorInfo.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
ActivatorInfo.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,41 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class ActivatorStateNotification : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.ActivatorStateNotification;
public ActivatorInfo ActivatorInfo { get; set; } = new();
public ActivatorStateNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
ActivatorInfo = new(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
ActivatorInfo.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
ActivatorInfo.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,67 @@
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class ActivatorStateResult : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.ActivatorStateResult;
public List<ActivatorInfo> ActivatorInfo { get; } = [];
public ActivatorStateResult() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
VariableLengthQuantity activatorNum = new(ref arr, ref idx);
//ActivatorInfo = [];
for (int i = 1; i <= activatorNum.Value; i++)
{
//ActivatorInfo.Add((Enumerations.ActivatorState)PrimitiveType.DeserializeEnum(ref arr, ref idx));
//ActivatorInfo.Add((Enumerations.ActivatorState)PrimitiveType.DeserializeEnum(ref arr, ref idx));
ActivatorInfo.Add(new(ref arr, ref idx));
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
if (ActivatorInfo != null)
{
new VariableLengthQuantity((uint)ActivatorInfo.Count).Serialize(ref arr);
foreach (var info in ActivatorInfo)
{
//arr.AddRange(PrimitiveType.SerializeEnum((Int16)act));
//arr.AddRange(act.Serialize());
info.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
if (ActivatorInfo != null)
{
foreach (var info in ActivatorInfo)
{
info.LogString(ref sb);
//sb.Append(" State='");
//sb.Append(state.ToString());
//sb.Append('\'');
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,44 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class DoorStateNotification : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DoorStateNotification;
public Enumerations.DoorState State { get; set; }
public DoorStateNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
State = (Enumerations.DoorState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,44 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class DoorStateResult : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DoorStateResult;
public Enumerations.DoorState State { get; set; }
public DoorStateResult() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
State = (Enumerations.DoorState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,40 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class GetActivatorStateCommand : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetActivatorStateCommand;
public GetActivatorStateCommand() { }
public GetActivatorStateCommand(string deviceGroupId)
{
DeviceGroupId = new Id(deviceGroupId);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,40 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class GetDoorStateCommand : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetDoorStateCommand;
public GetDoorStateCommand() { }
public GetDoorStateCommand(string deviceGroupId)
{
DeviceGroupId = new Id(deviceGroupId);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,40 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class GetHandleStateCommand : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetHandleStateCommand;
public GetHandleStateCommand() { }
public GetHandleStateCommand(string deviceGroupId)
{
DeviceGroupId = new Id(deviceGroupId);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,40 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class GetKeyCylinderStateCommand : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetKeyCylinderStateCommand;
public GetKeyCylinderStateCommand() { }
public GetKeyCylinderStateCommand(string deviceGroupId)
{
DeviceGroupId = new Id(deviceGroupId);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,40 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class GetLockStateCommand : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetLockStateCommand;
public GetLockStateCommand() { }
public GetLockStateCommand(string deviceGroupId)
{
DeviceGroupId = new Id(deviceGroupId);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,40 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class GetTamperStateCommand : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetTamperStateCommand;
public GetTamperStateCommand() { }
public GetTamperStateCommand(string deviceGroupId)
{
DeviceGroupId = new Id(deviceGroupId);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,44 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class HandleStateNotification : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.HandleStateNotification;
public Enumerations.HandleState State { get; set; }
public HandleStateNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
State = (Enumerations.HandleState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,44 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class HandleStateResult : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.HandleStateResult;
public Enumerations.HandleState State { get; set; }
public HandleStateResult() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
State = (Enumerations.HandleState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,44 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class KeyCylinderStateNotification : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.KeyCylinderStateNotification;
public Enumerations.KeyCylinderState State { get; set; }
public KeyCylinderStateNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
State = (Enumerations.KeyCylinderState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,44 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class KeyCylinderStateResult : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.KeyCylinderStateResult;
public Enumerations.KeyCylinderState State { get; set; }
public KeyCylinderStateResult() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
State = (Enumerations.KeyCylinderState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,44 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class LockStateNotification : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.LockStateNotification;
public Enumerations.LockState State { get; set; }
public LockStateNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
State = (Enumerations.LockState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,44 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class LockStateResult : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.LockStateResult;
public Enumerations.LockState State { get; set; }
public LockStateResult() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
State = (Enumerations.LockState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,44 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class TamperStateNotification : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.TamperStateNotification;
public Enumerations.TamperState State { get; set; }
public TamperStateNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
State = (Enumerations.TamperState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,44 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DeviceStates
{
public class TamperStateResult : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.TamperStateResult;
public Enumerations.TamperState State { get; set; }
public TamperStateResult() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
State = (Enumerations.TamperState)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)State));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" State-'");
sb.Append(State.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -1,747 +0,0 @@
using Aperio_Control_Centre.Aadp.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp
{
public class DoorOpeningCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DoorOpeningCommand;
public Id DeviceGroupId { get; set; } = new();
public bool Open { get; set; } //True, the Door shall be opened if it is supported by the Door. False, the Door is only unlocked.
public bool StandardIndication { get; set; }
public Timing Duration { get; set; } = new();
public DoorOpeningCommand() { }
public DoorOpeningCommand(string devid, bool open, bool indication, uint time, Enumerations.TimingMode mode)
{
DeviceGroupId = new Id(devid);
Open = open;
StandardIndication = indication;
Duration = new Timing(time, mode);
}
public DoorOpeningCommand(Id id, bool open, bool indication, uint time, Enumerations.TimingMode mode)
{
DeviceGroupId = id;
Open = open;
StandardIndication = indication;
Duration = new Timing(time, mode);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
Open = PrimitiveType.DeserializeBoolean(ref arr, ref idx);
StandardIndication = PrimitiveType.DeserializeBoolean(ref arr, ref idx);
Duration = new Timing(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeBoolean(Open));
arr.AddRange(PrimitiveType.SerializeBoolean(StandardIndication));
Duration.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Open-'");
sb.Append(Open);
sb.Append("' Indication-'");
sb.Append(StandardIndication);
sb.Append("' Duration(");
Duration.LogString(ref sb);
sb.Append(')');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class DoorOpeningResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DoorOpeningResult;
public Id DeviceGroupId { get; set; } = new();
public Enumerations.Status Result { get; set; }
public DoorOpeningResult() { }
public DoorOpeningResult(String devid, Enumerations.Status status)
{
DeviceGroupId = new Id(devid);
Result = status;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
Result = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Result));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Result-'");
sb.Append(Result.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetSupportedDoorModesCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetSupportedDoorModesCommand;
public Id DeviceGroupId { get; set; } = new();
public GetSupportedDoorModesCommand() { }
public GetSupportedDoorModesCommand(String devId)
{
DeviceGroupId = new Id(devId);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetSupportedDoorModesResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetSupportedDoorModesResult;
public Id DeviceGroupId { get; private set; } = new();
public List<Enumerations.DoorMode> DoorModes { get; private set; } = [];
public GetSupportedDoorModesResult() { }
public GetSupportedDoorModesResult(String devId, List<Enumerations.DoorMode> doorModes)
{
DeviceGroupId = new Id(devId);
DoorModes = doorModes;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
DoorModes = [];
for (int i = 1; i <= arrlen.Value; i++)
{
DoorModes.Add((Enumerations.DoorMode)PrimitiveType.DeserializeEnum(ref arr, ref idx));
}
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
if (DoorModes != null)
{
new VariableLengthQuantity((uint)DoorModes.Count).Serialize(ref arr);
foreach (var doormode in DoorModes)
{
arr.AddRange(PrimitiveType.SerializeEnum((Int16)doormode));
}
}
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
if (DoorModes != null)
{
foreach (var mode in DoorModes)
{
sb.Append(" - ");
sb.Append(mode.ToString());
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class SetDoorModeCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.SetDoorModeCommand;
public Id DeviceGroupId { get; set; } = new();
public Enumerations.DoorMode Mode { get; set; }
public Timing Duration { get; set; } = new();
public Enumerations.ExecuteMode Exec { get; set; }
public SetDoorModeCommand() { }
public SetDoorModeCommand(String id, Enumerations.DoorMode doorMode, uint time, Enumerations.TimingMode mode, Enumerations.ExecuteMode execute)
{
DeviceGroupId = new Id(id);
Mode = doorMode;
Duration = new Timing(time, mode);
Exec = execute;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
Mode = (Enumerations.DoorMode)PrimitiveType.DeserializeEnum(ref arr, ref idx);
Duration = new Timing(ref arr, ref idx);
Exec = (Enumerations.ExecuteMode)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Mode));
Duration.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Exec));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Mode-'");
sb.Append(Mode.ToString());
sb.Append("' ");
Duration.LogString(ref sb);
sb.Append(" ExecuteMode-'");
sb.Append(Exec.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class SetDoorModeResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.SetDoorModeResult;
public Id DeviceGroupId { get; set; } = new();
public Enumerations.Status Result { get; set; }
public SetDoorModeResult() { }
public SetDoorModeResult(string devId, Enumerations.Status result)
{
DeviceGroupId = new Id(devId);
Result = result;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
Result = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Result));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Result-'");
sb.Append(Result.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetDoorModeCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetDoorModeCommand;
public Id DeviceGroupId { get; set; } = new();
public GetDoorModeCommand() { }
public GetDoorModeCommand(String id)
{
DeviceGroupId = new Id(id);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetDoorModeResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetDoorModeResult;
public Id DeviceGroupId { get; set; } = new();
public Enumerations.DoorMode Mode { get; set; }
public GetDoorModeResult() { }
public GetDoorModeResult(string devId, Enumerations.DoorMode doorMode)
{
DeviceGroupId = new Id(devId);
Mode = doorMode;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
Mode = (Enumerations.DoorMode)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Mode));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Mode-'");
sb.Append(Mode.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class DoorModeNotification : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DoorModeNotification;
public Id DeviceGroupId { get; set; } = new();
public Enumerations.DoorMode Mode { get; set; }
public DoorModeNotification() { }
public DoorModeNotification(string devId, Enumerations.DoorMode mode)
{
DeviceGroupId = new Id(devId);
Mode = mode;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
Mode = (Enumerations.DoorMode)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Mode));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Mode-'");
sb.Append(Mode.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class SetCredentialCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.SetCredentialCommand;
public DeviceId DeviceGroupId { get; set; } = new();
public PacketSequenceNumber PacketSequenceNumber { get; set; } = new();
private static Enumerations.DeviceParameterType Reserved => Enumerations.DeviceParameterType.RESERVED;
public Enumerations.ExpireType CredentialExpireType { get; set; }
public VariableLengthQuantity CredentialExpireLimit { get; set; } = new();
public List<CredentialBlock> Credential { get; private set; } = [];
public SetCredentialCommand() { }
public SetCredentialCommand(string devId, Enumerations.ExpireType expireType, uint expireLimit, List<CredentialBlock> credentials)
{
DeviceGroupId = new DeviceId(devId);
PacketSequenceNumber = new PacketSequenceNumber();
CredentialExpireType = expireType;
CredentialExpireLimit = new VariableLengthQuantity(expireLimit);
Credential = credentials;
}
public SetCredentialCommand(byte[] devId, Enumerations.ExpireType expireType, uint expireLimit, List<CredentialBlock> credentials)
{
DeviceGroupId = new DeviceId(devId);
PacketSequenceNumber = new PacketSequenceNumber();
CredentialExpireType = expireType;
CredentialExpireLimit = new VariableLengthQuantity(expireLimit);
Credential = credentials;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new DeviceId(ref arr, ref idx);
PacketSequenceNumber = new PacketSequenceNumber(ref arr, ref idx);
idx += 1; //Reserved enum
CredentialExpireType = (Enumerations.ExpireType)PrimitiveType.DeserializeEnum(ref arr, ref idx);
CredentialExpireLimit = new VariableLengthQuantity(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
Credential = [];
for (int i = 1; i <= arrlen.Value; i++)
{
CredentialBlock credential = new(ref arr, ref idx);
Credential.Add(credential);
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
PacketSequenceNumber.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Reserved));
arr.AddRange(PrimitiveType.SerializeEnum((Int16)CredentialExpireType));
CredentialExpireLimit.Serialize(ref arr);
if (Credential != null)
{
new VariableLengthQuantity((uint)Credential.Count).Serialize(ref arr);
foreach (var cred in Credential)
{
cred.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
PacketSequenceNumber.LogString(ref sb);
sb.Append(" ExpireType-'" + CredentialExpireType.ToString() + "'");
sb.Append(" ExpireLimit-'");
CredentialExpireLimit.LogString(ref sb);
sb.Append('\'');
if (Credential != null)
{
foreach (var cred in Credential)
{
cred.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class SetCredentialResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.SetCredentialResult;
public DeviceId DeviceGroupId { get; set; } = new();
public Enumerations.Status Result { get; set; }
public SetCredentialResult() { }
public SetCredentialResult(string devId, Enumerations.Status result)
{
DeviceGroupId = new DeviceId(devId);
Result = result;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new DeviceId(ref arr, ref idx);
Result = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Result));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Result-'");
sb.Append(Result.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class DeleteCredentialCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DeleteCredentialCommand;
public DeviceId DeviceGroupId { get; set; } = new();
public PacketSequenceNumber PacketSequenceNumber { get; set; } = new();
private static Enumerations.DeviceParameterType Reserved => Enumerations.DeviceParameterType.RESERVED;
public Enumerations.CredentialDeleteMode Mode { get; set; }
public List<CredentialBlock> Credential { get; private set; } = [];
public DeleteCredentialCommand() { }
public DeleteCredentialCommand(string devid, Enumerations.CredentialDeleteMode mode, List<CredentialBlock> credentials)
{
DeviceGroupId = new DeviceId(devid);
PacketSequenceNumber = new PacketSequenceNumber();
Mode = mode;
Credential = credentials;
}
public DeleteCredentialCommand(DeviceId id, Enumerations.CredentialDeleteMode mode, ushort sequenceNumber)
{
DeviceGroupId = id;
PacketSequenceNumber = new PacketSequenceNumber(sequenceNumber);
Mode = mode;
}
public DeleteCredentialCommand(DeviceId id, Enumerations.CredentialDeleteMode mode)
{
DeviceGroupId = id;
PacketSequenceNumber = new PacketSequenceNumber();
Mode = mode;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new DeviceId(ref arr, ref idx);
PacketSequenceNumber = new PacketSequenceNumber(ref arr, ref idx);
idx += 1; //Reserved Enum
Mode = (Enumerations.CredentialDeleteMode)PrimitiveType.DeserializeEnum(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
Credential = [];
for (int i = 1; i <= arrlen.Value; i++)
{
CredentialBlock credential = new(ref arr, ref idx);
Credential.Add(credential);
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
PacketSequenceNumber.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Reserved));
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Mode));
if (Mode == Enumerations.CredentialDeleteMode.DELETE_SINGLE)
{
if (Credential != null)
{
new VariableLengthQuantity((uint)Credential.Count).Serialize(ref arr);
foreach (var cred in Credential)
{
cred.Serialize(ref arr);
}
}
}
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
PacketSequenceNumber.LogString(ref sb);
sb.Append(" Mode = " + Mode.ToString());
if (Credential != null)
{
foreach (var cred in Credential)
{
cred.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class DeleteCredentialResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DeleteCredentialResult;
public DeviceId DeviceGroupId { get; set; } = new();
public Enumerations.Status Result { get; set; }
public DeleteCredentialResult() { }
public DeleteCredentialResult(string devId, Enumerations.Status result)
{
DeviceGroupId = new DeviceId(devId);
Result = result;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new DeviceId(ref arr, ref idx);
Result = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Result));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Result-'");
sb.Append(Result.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class CredentialManagementNotification : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.CredentialManagementNotification;
public DeviceId DeviceGroupId { get; set; } = new();
public PacketSequenceNumber PacketSequenceNumber { get; set; } = new();
private static Enumerations.DeviceParameterType Reserved => Enumerations.DeviceParameterType.RESERVED;
public Enumerations.CredentialManagementNotificationType Notification { get; set; }
public CredentialManagementNotification() { }
public CredentialManagementNotification(string devId, Enumerations.CredentialManagementNotificationType notification)
{
DeviceGroupId = new DeviceId(devId);
PacketSequenceNumber = new PacketSequenceNumber();
Notification = notification;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new DeviceId(ref arr, ref idx);
PacketSequenceNumber = new PacketSequenceNumber(ref arr, ref idx);
idx += 1; //Reserved Enum
Notification = (Enumerations.CredentialManagementNotificationType)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
PacketSequenceNumber.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Reserved));
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Notification));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
PacketSequenceNumber.LogString(ref sb);
sb.Append(" Notification-'");
sb.Append(Notification.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,58 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DoorControl
{
public class CredentialManagementNotification : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.CredentialManagementNotification;
public DeviceId DeviceGroupId { get; set; } = new();
public PacketSequenceNumber PacketSequenceNumber { get; set; } = new();
private static Enumerations.DeviceParameterType Reserved => Enumerations.DeviceParameterType.RESERVED;
public Enumerations.CredentialManagementNotificationType Notification { get; set; }
public CredentialManagementNotification() { }
public CredentialManagementNotification(string devId, Enumerations.CredentialManagementNotificationType notification)
{
DeviceGroupId = new DeviceId(devId);
PacketSequenceNumber = new PacketSequenceNumber();
Notification = notification;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new DeviceId(ref arr, ref idx);
PacketSequenceNumber = new PacketSequenceNumber(ref arr, ref idx);
idx += 1; //Reserved Enum
Notification = (Enumerations.CredentialManagementNotificationType)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
PacketSequenceNumber.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Reserved));
arr.AddRange(PrimitiveType.SerializeEnum((short)Notification));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
PacketSequenceNumber.LogString(ref sb);
sb.Append(" Notification-'");
sb.Append(Notification.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,96 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DoorControl
{
public class DeleteCredentialCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DeleteCredentialCommand;
public DeviceId DeviceGroupId { get; set; } = new();
public PacketSequenceNumber PacketSequenceNumber { get; set; } = new();
private static Enumerations.DeviceParameterType Reserved => Enumerations.DeviceParameterType.RESERVED;
public Enumerations.CredentialDeleteMode Mode { get; set; }
public List<CredentialBlock> Credential { get; private set; } = [];
public DeleteCredentialCommand() { }
public DeleteCredentialCommand(string devid, Enumerations.CredentialDeleteMode mode, List<CredentialBlock> credentials)
{
DeviceGroupId = new DeviceId(devid);
PacketSequenceNumber = new PacketSequenceNumber();
Mode = mode;
Credential = credentials;
}
public DeleteCredentialCommand(DeviceId id, Enumerations.CredentialDeleteMode mode, ushort sequenceNumber)
{
DeviceGroupId = id;
PacketSequenceNumber = new PacketSequenceNumber(sequenceNumber);
Mode = mode;
}
public DeleteCredentialCommand(DeviceId id, Enumerations.CredentialDeleteMode mode)
{
DeviceGroupId = id;
PacketSequenceNumber = new PacketSequenceNumber();
Mode = mode;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new DeviceId(ref arr, ref idx);
PacketSequenceNumber = new PacketSequenceNumber(ref arr, ref idx);
idx += 1; //Reserved Enum
Mode = (Enumerations.CredentialDeleteMode)PrimitiveType.DeserializeEnum(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
Credential = [];
for (int i = 1; i <= arrlen.Value; i++)
{
CredentialBlock credential = new(ref arr, ref idx);
Credential.Add(credential);
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
PacketSequenceNumber.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Reserved));
arr.AddRange(PrimitiveType.SerializeEnum((short)Mode));
if (Mode == Enumerations.CredentialDeleteMode.DELETE_SINGLE)
{
if (Credential != null)
{
new VariableLengthQuantity((uint)Credential.Count).Serialize(ref arr);
foreach (var cred in Credential)
{
cred.Serialize(ref arr);
}
}
}
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
PacketSequenceNumber.LogString(ref sb);
sb.Append(" Mode = " + Mode.ToString());
if (Credential != null)
{
foreach (var cred in Credential)
{
cred.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,50 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DoorControl
{
public class DeleteCredentialResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DeleteCredentialResult;
public DeviceId DeviceGroupId { get; set; } = new();
public Enumerations.Status Result { get; set; }
public DeleteCredentialResult() { }
public DeleteCredentialResult(string devId, Enumerations.Status result)
{
DeviceGroupId = new DeviceId(devId);
Result = result;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new DeviceId(ref arr, ref idx);
Result = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Result));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Result-'");
sb.Append(Result.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,49 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DoorControl
{
public class DoorModeNotification : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DoorModeNotification;
public Enumerations.DoorMode Mode { get; set; }
public DoorModeNotification() { }
public DoorModeNotification(string devId, Enumerations.DoorMode mode)
{
DeviceGroupId = new Id(devId);
Mode = mode;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
Mode = (Enumerations.DoorMode)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Mode));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Mode-'");
sb.Append(Mode.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,69 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DoorControl
{
public class DoorOpeningCommand : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DoorOpeningCommand;
public bool Open { get; set; } //True, the Door shall be opened if it is supported by the Door. False, the Door is only unlocked.
public bool StandardIndication { get; set; }
public Timing Duration { get; set; } = new();
public DoorOpeningCommand() { }
public DoorOpeningCommand(string devid, bool open, bool indication, uint time, Enumerations.TimingMode mode)
{
DeviceGroupId = new Id(devid);
Open = open;
StandardIndication = indication;
Duration = new Timing(time, mode);
}
public DoorOpeningCommand(Id id, bool open, bool indication, uint time, Enumerations.TimingMode mode)
{
DeviceGroupId = id;
Open = open;
StandardIndication = indication;
Duration = new Timing(time, mode);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
Open = PrimitiveType.DeserializeBoolean(ref arr, ref idx);
StandardIndication = PrimitiveType.DeserializeBoolean(ref arr, ref idx);
Duration = new Timing(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeBoolean(Open));
arr.AddRange(PrimitiveType.SerializeBoolean(StandardIndication));
Duration.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Open-'");
sb.Append(Open);
sb.Append("' Indication-'");
sb.Append(StandardIndication);
sb.Append("' Duration(");
Duration.LogString(ref sb);
sb.Append(')');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,49 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DoorControl
{
public class DoorOpeningResult : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DoorOpeningResult;
public Enumerations.Status Result { get; set; }
public DoorOpeningResult() { }
public DoorOpeningResult(string devid, Enumerations.Status status)
{
DeviceGroupId = new Id(devid);
Result = status;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
Result = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Result));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Result-'");
sb.Append(Result.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,40 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DoorControl
{
public class GetDoorModeCommand : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetDoorModeCommand;
public GetDoorModeCommand() { }
public GetDoorModeCommand(string id)
{
DeviceGroupId = new Id(id);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,49 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DoorControl
{
public class GetDoorModeResult : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetDoorModeResult;
public Enumerations.DoorMode Mode { get; set; }
public GetDoorModeResult() { }
public GetDoorModeResult(string devId, Enumerations.DoorMode doorMode)
{
DeviceGroupId = new Id(devId);
Mode = doorMode;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
Mode = (Enumerations.DoorMode)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Mode));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Mode-'");
sb.Append(Mode.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,40 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DoorControl
{
public class GetSupportedDoorModesCommand : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetSupportedDoorModesCommand;
public GetSupportedDoorModesCommand() { }
public GetSupportedDoorModesCommand(string devId)
{
DeviceGroupId = new Id(devId);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,67 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DoorControl
{
public class GetSupportedDoorModesResult : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetSupportedDoorModesResult;
public List<Enumerations.DoorMode> DoorModes { get; private set; } = [];
public GetSupportedDoorModesResult() { }
public GetSupportedDoorModesResult(string devId, List<Enumerations.DoorMode> doorModes)
{
DeviceGroupId = new Id(devId);
DoorModes = doorModes;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
DoorModes = [];
for (int i = 1; i <= arrlen.Value; i++)
{
DoorModes.Add((Enumerations.DoorMode)PrimitiveType.DeserializeEnum(ref arr, ref idx));
}
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
if (DoorModes != null)
{
new VariableLengthQuantity((uint)DoorModes.Count).Serialize(ref arr);
foreach (var doormode in DoorModes)
{
arr.AddRange(PrimitiveType.SerializeEnum((short)doormode));
}
}
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
if (DoorModes != null)
{
foreach (var mode in DoorModes)
{
sb.Append(" - ");
sb.Append(mode.ToString());
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,96 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DoorControl
{
public class SetCredentialCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.SetCredentialCommand;
public DeviceId DeviceGroupId { get; set; } = new();
public PacketSequenceNumber PacketSequenceNumber { get; set; } = new();
private static Enumerations.DeviceParameterType Reserved => Enumerations.DeviceParameterType.RESERVED;
public Enumerations.ExpireType CredentialExpireType { get; set; }
public VariableLengthQuantity CredentialExpireLimit { get; set; } = new();
public List<CredentialBlock> Credential { get; private set; } = [];
public SetCredentialCommand() { }
public SetCredentialCommand(string devId, Enumerations.ExpireType expireType, uint expireLimit, List<CredentialBlock> credentials)
{
DeviceGroupId = new DeviceId(devId);
PacketSequenceNumber = new PacketSequenceNumber();
CredentialExpireType = expireType;
CredentialExpireLimit = new VariableLengthQuantity(expireLimit);
Credential = credentials;
}
public SetCredentialCommand(byte[] devId, Enumerations.ExpireType expireType, uint expireLimit, List<CredentialBlock> credentials)
{
DeviceGroupId = new DeviceId(devId);
PacketSequenceNumber = new PacketSequenceNumber();
CredentialExpireType = expireType;
CredentialExpireLimit = new VariableLengthQuantity(expireLimit);
Credential = credentials;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new DeviceId(ref arr, ref idx);
PacketSequenceNumber = new PacketSequenceNumber(ref arr, ref idx);
idx += 1; //Reserved enum
CredentialExpireType = (Enumerations.ExpireType)PrimitiveType.DeserializeEnum(ref arr, ref idx);
CredentialExpireLimit = new VariableLengthQuantity(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
Credential = [];
for (int i = 1; i <= arrlen.Value; i++)
{
CredentialBlock credential = new(ref arr, ref idx);
Credential.Add(credential);
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
PacketSequenceNumber.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Reserved));
arr.AddRange(PrimitiveType.SerializeEnum((short)CredentialExpireType));
CredentialExpireLimit.Serialize(ref arr);
if (Credential != null)
{
new VariableLengthQuantity((uint)Credential.Count).Serialize(ref arr);
foreach (var cred in Credential)
{
cred.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
PacketSequenceNumber.LogString(ref sb);
sb.Append(" ExpireType-'" + CredentialExpireType.ToString() + "'");
sb.Append(" ExpireLimit-'");
CredentialExpireLimit.LogString(ref sb);
sb.Append('\'');
if (Credential != null)
{
foreach (var cred in Credential)
{
cred.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,50 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DoorControl
{
public class SetCredentialResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.SetCredentialResult;
public DeviceId DeviceGroupId { get; set; } = new();
public Enumerations.Status Result { get; set; }
public SetCredentialResult() { }
public SetCredentialResult(string devId, Enumerations.Status result)
{
DeviceGroupId = new DeviceId(devId);
Result = result;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new DeviceId(ref arr, ref idx);
Result = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Result));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Result-'");
sb.Append(Result.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,61 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DoorControl
{
public class SetDoorModeCommand : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.SetDoorModeCommand;
public Enumerations.DoorMode Mode { get; set; }
public Timing Duration { get; set; } = new();
public Enumerations.ExecuteMode Exec { get; set; }
public SetDoorModeCommand() { }
public SetDoorModeCommand(string id, Enumerations.DoorMode doorMode, uint time, Enumerations.TimingMode mode, Enumerations.ExecuteMode execute)
{
DeviceGroupId = new Id(id);
Mode = doorMode;
Duration = new Timing(time, mode);
Exec = execute;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
Mode = (Enumerations.DoorMode)PrimitiveType.DeserializeEnum(ref arr, ref idx);
Duration = new Timing(ref arr, ref idx);
Exec = (Enumerations.ExecuteMode)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Mode));
Duration.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Exec));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Mode-'");
sb.Append(Mode.ToString());
sb.Append("' ");
Duration.LogString(ref sb);
sb.Append(" ExecuteMode-'");
sb.Append(Exec.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,49 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.DoorControl
{
public class SetDoorModeResult : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.SetDoorModeResult;
public Enumerations.Status Result { get; set; }
public SetDoorModeResult() { }
public SetDoorModeResult(string devId, Enumerations.Status result)
{
DeviceGroupId = new Id(devId);
Result = result;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
Result = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Result));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Result-'");
sb.Append(Result.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -1,4 +1,4 @@
namespace Aperio_Control_Centre.Aadp
namespace Aperio_Control_Centre.Aadp.Commands
{
public interface IPduCommand
{
@@ -21,77 +21,4 @@
// return arr.ToArray();
//}
}
public static class PduMessageInvoker
{
public static IPduCommand GetMessage(VariableLengthQuantity messageType)
{
return (Enumerations.PDUTypes)messageType.Value switch
{
Enumerations.PDUTypes.HelloRequest => new HelloRequest(),
Enumerations.PDUTypes.HelloResponse => new HelloResponse(),
Enumerations.PDUTypes.DeviceGroupInfoNotification => new DeviceGroupInfoNotification(),
Enumerations.PDUTypes.CredentialNotification => new CredentialNotification(),
Enumerations.PDUTypes.KeypadNotification => new KeypadNotification(),
Enumerations.PDUTypes.RestartCommand => new RestartCommand(),
Enumerations.PDUTypes.IndicationCommand => new IndicationCommand(),
Enumerations.PDUTypes.IndicationResult => new IndicationResult(),
Enumerations.PDUTypes.GetSupportedDoorModesCommand => new GetSupportedDoorModesCommand(),
Enumerations.PDUTypes.GetSupportedDoorModesResult => new GetSupportedDoorModesResult(),
Enumerations.PDUTypes.DoorOpeningCommand => new DoorOpeningCommand(),
Enumerations.PDUTypes.DoorOpeningResult => new DoorOpeningResult(),
Enumerations.PDUTypes.SetDoorModeCommand => new SetDoorModeCommand(),
Enumerations.PDUTypes.SetDoorModeResult => new SetDoorModeResult(),
Enumerations.PDUTypes.StatusRequest => new StatusRequest(),
Enumerations.PDUTypes.StatusResponse => new StatusResponse(),
Enumerations.PDUTypes.GetDeviceParameterCommand => new GetDeviceParameterCommand(),
Enumerations.PDUTypes.GetDeviceParameterResult => new GetDeviceParameterResult(),
Enumerations.PDUTypes.DtcNotification => new DtcNotification(),
Enumerations.PDUTypes.GetDtcStatusCommand => new GetDtcStatusCommand(),
Enumerations.PDUTypes.GetDtcStatusResult => new GetDtcStatusResult(),
Enumerations.PDUTypes.ClearDtcCommand => new ClearDtcCommand(),
Enumerations.PDUTypes.ClearDtcResult => new ClearDtcResult(),
Enumerations.PDUTypes.GetDeviceListCommand => new GetDeviceListCommand(),
Enumerations.PDUTypes.DeviceListResult => new DeviceListResult(),
Enumerations.PDUTypes.GetAuditTrailCommand => new GetAuditTrailCommand(),
Enumerations.PDUTypes.GetAuditTrailResult => new GetAuditTrailResult(),
Enumerations.PDUTypes.AuditTrailNotification => new AuditTrailNotification(),
Enumerations.PDUTypes.TimeNotification => new TimeNotification(),
Enumerations.PDUTypes.SetTimeCommand => new SetTimeCommand(),
Enumerations.PDUTypes.SetTimeResult => new SetTimeResult(),
Enumerations.PDUTypes.GetTimeCommand => new GetTimeCommand(),
Enumerations.PDUTypes.GetTimeResult => new GetTimeResult(),
Enumerations.PDUTypes.SetDeviceParameterCommand => new SetDeviceParameterCommand(),
Enumerations.PDUTypes.SetDeviceParameterResult => new SetDeviceParameterResult(),
Enumerations.PDUTypes.DeviceParameterNotification => new DeviceParameterNotification(),
Enumerations.PDUTypes.SetCredentialCommand => new SetCredentialCommand(),
Enumerations.PDUTypes.SetCredentialResult => new SetCredentialResult(),
Enumerations.PDUTypes.DeleteCredentialCommand => new DeleteCredentialCommand(),
Enumerations.PDUTypes.DeleteCredentialResult => new DeleteCredentialResult(),
Enumerations.PDUTypes.CredentialManagementNotification => new CredentialManagementNotification(),
Enumerations.PDUTypes.GetDoorStateCommand => new GetDoorStateCommand(),
Enumerations.PDUTypes.DoorStateResult => new DoorStateResult(),
Enumerations.PDUTypes.DoorStateNotification => new DoorStateNotification(),
Enumerations.PDUTypes.GetLockStateCommand => new GetLockStateCommand(),
Enumerations.PDUTypes.LockStateResult => new LockStateResult(),
Enumerations.PDUTypes.LockStateNotification => new LockStateNotification(),
Enumerations.PDUTypes.GetKeyCylinderStateCommand => new GetKeyCylinderStateCommand(),
Enumerations.PDUTypes.KeyCylinderStateResult => new KeyCylinderStateResult(),
Enumerations.PDUTypes.KeyCylinderStateNotification => new KeyCylinderStateNotification(),
Enumerations.PDUTypes.GetHandleStateCommand => new GetHandleStateCommand(),
Enumerations.PDUTypes.HandleStateResult => new HandleStateResult(),
Enumerations.PDUTypes.HandleStateNotification => new HandleStateNotification(),
Enumerations.PDUTypes.GetTamperStateCommand => new GetTamperStateCommand(),
Enumerations.PDUTypes.TamperStateResult => new TamperStateResult(),
Enumerations.PDUTypes.TamperStateNotification => new TamperStateNotification(),
Enumerations.PDUTypes.GetActivatorStateCommand => new GetActivatorStateCommand(),
Enumerations.PDUTypes.ActivatorStateResult => new ActivatorStateResult(),
Enumerations.PDUTypes.ActivatorStateNotification => new ActivatorStateNotification(),
Enumerations.PDUTypes.GetDoorModeCommand => new GetDoorModeCommand(),
Enumerations.PDUTypes.GetDoorModeResult => new GetDoorModeResult(),
Enumerations.PDUTypes.DoorModeNotification => new DoorModeNotification(),
_ => new CommandError("Unknown PDU Type"),
};
}
}
}

View File

@@ -1,14 +1,15 @@
using System.Text;
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp
namespace Aperio_Control_Centre.Aadp.Commands.InputFromUser
{
public class CredentialNotification : IPduCommand
public class CredentialNotification : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.CredentialNotification;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public Enumerations.DoorSide DoorSide { get; set; }
public List<ApplicationTypes.CredentialBlock> Credential { get; } = [];
public List<CredentialBlock> Credential { get; } = [];
public string GetCredentialTypeData(Enumerations.CredentialBlockType blockType)
{
@@ -17,33 +18,33 @@ namespace Aperio_Control_Centre.Aadp
{
return cred.Characters;
}
return String.Empty;
return string.Empty;
}
public CredentialNotification() { }
public CredentialNotification(string deviceGroupId, Enumerations.DoorSide doorSide)
{
DeviceGroupId = new ApplicationTypes.Id(deviceGroupId);
DeviceGroupId = new Id(deviceGroupId);
DoorSide = doorSide;
Credential = [];
}
public CredentialNotification(string deviceGroupId, Enumerations.DoorSide doorSide, List<ApplicationTypes.CredentialBlock> Credentials)
public CredentialNotification(string deviceGroupId, Enumerations.DoorSide doorSide, List<CredentialBlock> Credentials)
{
DeviceGroupId = new ApplicationTypes.Id(deviceGroupId);
DeviceGroupId = new Id(deviceGroupId);
DoorSide = doorSide;
Credential = Credentials;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
DeviceGroupId = new Id(ref arr, ref idx);
DoorSide = (Enumerations.DoorSide)PrimitiveType.DeserializeEnum(ref arr, ref idx);
VariableLengthQuantity crednum = new(ref arr, ref idx);
//Credential = [];
for (int i = 1; i <= crednum.Value; i++)
{
ApplicationTypes.CredentialBlock credential = new(ref arr, ref idx);
CredentialBlock credential = new(ref arr, ref idx);
Credential.Add(credential);
}
}
@@ -53,7 +54,7 @@ namespace Aperio_Control_Centre.Aadp
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)DoorSide));
arr.AddRange(PrimitiveType.SerializeEnum((short)DoorSide));
if (Credential != null)
{
new VariableLengthQuantity((uint)Credential.Count).Serialize(ref arr);
@@ -90,52 +91,4 @@ namespace Aperio_Control_Centre.Aadp
return PDUType.ToString();
}
}
public class KeypadNotification : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.KeypadNotification;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public Enumerations.DoorSide DoorSide { get; set; }
public string Keys { get; set; } = String.Empty;
public KeypadNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
DoorSide = (Enumerations.DoorSide)PrimitiveType.DeserializeEnum(ref arr, ref idx);
Keys = PrimitiveType.DeserializeString(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)DoorSide));
if (Keys != null)
{
arr.AddRange(PrimitiveType.SerializeString(Keys));
}
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Doorside-'");
sb.Append(DoorSide.ToString());
sb.Append('\'');
sb.Append(" Keys-'");
sb.Append(Keys);
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,53 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.InputFromUser
{
public class KeypadNotification : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.KeypadNotification;
public Enumerations.DoorSide DoorSide { get; set; }
public string Keys { get; set; } = string.Empty;
public KeypadNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
DoorSide = (Enumerations.DoorSide)PrimitiveType.DeserializeEnum(ref arr, ref idx);
Keys = PrimitiveType.DeserializeString(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)DoorSide));
if (Keys != null)
{
arr.AddRange(PrimitiveType.SerializeString(Keys));
}
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Doorside-'");
sb.Append(DoorSide.ToString());
sb.Append('\'');
sb.Append(" Keys-'");
sb.Append(Keys);
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -1,813 +0,0 @@
using Aperio_Control_Centre.Aadp.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp
{
public class StatusRequest : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.StatusRequest;
public Enumerations.Status Status { get; set; }
public StatusRequest() { }
public StatusRequest(Enumerations.Status state)
{
Status = state;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Status = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Status));
}
public string LogString()
{
StringBuilder sb = new();
sb.Append("Status-'");
sb.Append(Status.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class StatusResponse : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.StatusResponse;
public Enumerations.Status Status { get; set; }
public StatusResponse() { }
public StatusResponse(Enumerations.Status state)
{
Status = state;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Status = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Status));
}
public string LogString()
{
StringBuilder sb = new();
sb.Append("Status-'");
sb.Append(Status.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetDeviceListCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetDeviceListCommand;
public GetDeviceListCommand() { }
public void Deserialize(ref byte[] arr, ref int idx) { }
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
}
public string LogString()
{
return String.Empty;
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class DeviceListResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DeviceListResult;
public List<ApplicationTypes.DeviceDefinition> Devices { get; } = [];
public DeviceListResult() { }
public DeviceListResult(List<ApplicationTypes.DeviceDefinition> devices)
{
Devices = devices;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
VariableLengthQuantity arrlen = new(ref arr, ref idx);
//Devices = [];
for (int i = 1; i <= arrlen.Value; i++)
{
Devices.Add(new ApplicationTypes.DeviceDefinition(ref arr, ref idx));
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
if (Devices != null)
{
new VariableLengthQuantity((uint)Devices.Count).Serialize(ref arr);
foreach (ApplicationTypes.DeviceDefinition device in Devices)
{
device.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
sb.Append(Environment.NewLine);
if (Devices != null)
{
foreach (ApplicationTypes.DeviceDefinition dev in Devices)
{
dev.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class DtcNotification : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DtcNotification;
public ApplicationTypes.DeviceId Device { get; set; } = new();
public ApplicationTypes.DtcInfo DTC { get; set; } = new();
public DtcNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new ApplicationTypes.DeviceId(ref arr, ref idx);
DTC = new ApplicationTypes.DtcInfo(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
DTC.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" - ");
DTC.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetDtcStatusCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetDtcStatusCommand;
public ApplicationTypes.DeviceId Device { get; set; } = new();
public Enumerations.DtcSelection Selection { get; set; }
public VariableLengthQuantity MaxDtcs { get; set; } = new();
public VariableLengthQuantity Index { get; set; } = new();
public GetDtcStatusCommand() { }
public GetDtcStatusCommand(byte[] devid, uint max, uint idx)
{
Device = new ApplicationTypes.DeviceId(devid);
Selection = Enumerations.DtcSelection.ALL;
MaxDtcs = new VariableLengthQuantity(max);
Index = new VariableLengthQuantity(idx);
}
public GetDtcStatusCommand(DeviceId devid, uint max, uint idx)
{
Device = devid;
Selection = Enumerations.DtcSelection.ALL;
MaxDtcs = new VariableLengthQuantity(max);
Index = new VariableLengthQuantity(idx);
}
public GetDtcStatusCommand(DeviceId devid, uint max, uint idx, Enumerations.DtcSelection selection)
{
Device = devid;
Selection = selection;
MaxDtcs = new VariableLengthQuantity(max);
Index = new VariableLengthQuantity(idx);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new ApplicationTypes.DeviceId(ref arr, ref idx);
Selection = (Enumerations.DtcSelection)PrimitiveType.DeserializeEnum(ref arr, ref idx);
MaxDtcs = new VariableLengthQuantity(ref arr, ref idx);
Index = new VariableLengthQuantity(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Selection));
MaxDtcs.Serialize(ref arr);
Index.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" - ");
sb.Append(Selection.ToString());
sb.Append(" - ");
MaxDtcs.LogString(ref sb);
sb.Append(" - ");
Index.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetDtcStatusResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetDtcStatusResult;
public ApplicationTypes.DeviceId Device { get; set; } = new();
public List<ApplicationTypes.DtcInfo> DTCs { get; } = [];
public GetDtcStatusResult() { }
public GetDtcStatusResult(string devId, List<ApplicationTypes.DtcInfo> dtcInfos)
{
Device = new ApplicationTypes.DeviceId(devId);
DTCs = dtcInfos;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new ApplicationTypes.DeviceId(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
//DTCs = [];
for (int i = 1; i <= arrlen.Value; i++)
{
ApplicationTypes.DtcInfo dtcInfo = new(ref arr, ref idx);
DTCs.Add(dtcInfo);
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
if (DTCs != null)
{
new VariableLengthQuantity((uint)DTCs.Count).Serialize(ref arr);
foreach (ApplicationTypes.DtcInfo dtc in DTCs)
{
dtc.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
if (DTCs != null)
{
sb.Append(Environment.NewLine);
foreach (ApplicationTypes.DtcInfo dtc in DTCs)
{
dtc.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class ClearDtcCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.ClearDtcCommand;
public ApplicationTypes.DeviceId Device { get; set; } = new();
public VariableLengthQuantity DTCId { get; set; } = new();
public ClearDtcCommand() { }
public ClearDtcCommand(byte[] devid, uint id)
{
Device = new ApplicationTypes.DeviceId(devid);
DTCId = new VariableLengthQuantity(id);
}
public ClearDtcCommand(DeviceId devid, uint id)
{
Device = devid;
DTCId = new VariableLengthQuantity(id);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new ApplicationTypes.DeviceId(ref arr, ref idx);
DTCId = new VariableLengthQuantity(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
DTCId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" DTCid-'");
DTCId.LogString(ref sb);
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class ClearDtcResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.ClearDtcResult;
public ApplicationTypes.DeviceId Device { get; set; } = new();
public Enumerations.Status Result { get; set; }
public ClearDtcResult() { }
public ClearDtcResult(string devId, Enumerations.Status result)
{
Device = new ApplicationTypes.DeviceId(devId);
Result = result;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new ApplicationTypes.DeviceId(ref arr, ref idx);
Result = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Result));
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" Result-'");
sb.Append(Result.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetAuditTrailCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetAuditTrailCommand;
public ApplicationTypes.DeviceId Device { get; set; } = new();
public ApplicationTypes.PacketSequenceNumber SequenceNumber { get; set; } = new();
private static uint Reserved => 0;
public Enumerations.ReadSequence ReadSequence { get; set; }
public GetAuditTrailCommand() { }
public GetAuditTrailCommand(byte[] id, Enumerations.ReadSequence sequence)
{
Device = new ApplicationTypes.DeviceId(id);
SequenceNumber = new ApplicationTypes.PacketSequenceNumber();
ReadSequence = sequence;
}
public GetAuditTrailCommand(DeviceId id, Enumerations.ReadSequence sequence, ushort sequenceNumber)
{
Device = id;
SequenceNumber = new ApplicationTypes.PacketSequenceNumber(sequenceNumber);
ReadSequence = sequence;
}
public GetAuditTrailCommand(DeviceId id, Enumerations.ReadSequence sequence)
{
Device = id;
SequenceNumber = new ApplicationTypes.PacketSequenceNumber();
ReadSequence = sequence;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new ApplicationTypes.DeviceId(ref arr, ref idx);
SequenceNumber = new ApplicationTypes.PacketSequenceNumber(ref arr, ref idx);
idx += 1; //reserved enum
ReadSequence = (Enumerations.ReadSequence)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
SequenceNumber.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Reserved));
arr.AddRange(PrimitiveType.SerializeEnum((Int16)ReadSequence));
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
SequenceNumber.LogString(ref sb);
sb.Append(" Readsequence-'");
sb.Append(ReadSequence.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetAuditTrailResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetAuditTrailResult;
public ApplicationTypes.DeviceId Device { get; set; } = new();
public Enumerations.Status Result { get; set; }
public GetAuditTrailResult() { }
public GetAuditTrailResult(string devId, Enumerations.Status result)
{
Device = new ApplicationTypes.DeviceId(devId);
Result = result;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new ApplicationTypes.DeviceId(ref arr, ref idx);
Result = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Result));
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" Result-'");
sb.Append(Result.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class AuditTrailNotification : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.AuditTrailNotification;
public ApplicationTypes.DeviceId Device { get; set; } = new();
public ApplicationTypes.PacketSequenceNumber PacketSequence { get; set; } = new();
private static uint Reserved => 0;
public Enumerations.AuditTrailMessageType MessageType { get; set; }
public ApplicationTypes.TimeStamp TimeStamp { get; set; } = new();
public Enumerations.AccessDecision AccessDecision { get; set; }
public List<ApplicationTypes.CredentialBlock> Credential { get; } = [];
public AuditTrailNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new ApplicationTypes.DeviceId(ref arr, ref idx);
PacketSequence = new ApplicationTypes.PacketSequenceNumber(ref arr, ref idx);
idx += 1; //reserved enum
MessageType = (Enumerations.AuditTrailMessageType)PrimitiveType.DeserializeEnum(ref arr, ref idx);
TimeStamp = new ApplicationTypes.TimeStamp(ref arr, ref idx);
AccessDecision = (Enumerations.AccessDecision)PrimitiveType.DeserializeEnum(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
//Credential = [];
for (int i = 1; i <= arrlen.Value; i++)
{
ApplicationTypes.CredentialBlock cred = new(ref arr, ref idx);
Credential.Add(cred);
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
PacketSequence.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Reserved));
arr.AddRange(PrimitiveType.SerializeEnum((Int16)MessageType));
TimeStamp.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)AccessDecision));
if (Credential != null)
{
new VariableLengthQuantity((uint)Credential.Count).Serialize(ref arr);
foreach (var cred in Credential)
{
cred.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
PacketSequence.LogString(ref sb);
sb.Append(" MessageType = " + MessageType.ToString());
TimeStamp.LogString(ref sb);
sb.Append(" AccessDescision = " + AccessDecision.ToString());
if (Credential != null)
{
sb.Append(Environment.NewLine);
foreach (var cred in Credential)
{
cred.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class TimeNotification : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.TimeNotification;
public ApplicationTypes.DeviceId Device { get; set; } = new();
public ApplicationTypes.Time Time { get; set; } = new();
public TimeNotification() { }
public TimeNotification(string devid, DateTime dateTime)
{
Device = new ApplicationTypes.DeviceId(devid);
Time = new ApplicationTypes.Time(dateTime);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new ApplicationTypes.DeviceId(ref arr, ref idx);
Time = new ApplicationTypes.Time(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
Time.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" Time = ");
Time.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class SetTimeCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.SetTimeCommand;
public ApplicationTypes.DeviceId Device { get; set; } = new();
public ApplicationTypes.Time Time { get; set; } = new();
public SetTimeCommand() { }
public SetTimeCommand(Byte[] device, DateTime dateTime)
{
Device = new ApplicationTypes.DeviceId(device);
Time = new ApplicationTypes.Time(dateTime);
}
public SetTimeCommand(DeviceId device, DateTime dateTime)
{
Device = device;
Time = new ApplicationTypes.Time(dateTime);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new ApplicationTypes.DeviceId(ref arr, ref idx);
Time = new ApplicationTypes.Time(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
Time.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" - ");
Time.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class SetTimeResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.SetTimeResult;
public ApplicationTypes.DeviceId Device { get; set; } = new();
public Enumerations.Status Result { get; set; }
public SetTimeResult() { }
public SetTimeResult(string devId, Enumerations.Status result)
{
Device = new ApplicationTypes.DeviceId(devId);
Result = result;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new ApplicationTypes.DeviceId(ref arr, ref idx);
Result = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Result));
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" Result-'");
sb.Append(Result.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetTimeCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetTimeCommand;
public ApplicationTypes.DeviceId Device { get; set; } = new();
public GetTimeCommand() { }
public GetTimeCommand(Byte[] device)
{
Device = new ApplicationTypes.DeviceId(device);
}
public GetTimeCommand(DeviceId device)
{
Device = device;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new ApplicationTypes.DeviceId(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetTimeResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetTimeResult;
public ApplicationTypes.DeviceId Device { get; set; } = new();
public ApplicationTypes.Time Time { get; set; } = new();
public GetTimeResult() { }
public GetTimeResult(string devId, DateTime dateTime)
{
Device = new ApplicationTypes.DeviceId(devId);
Time = new ApplicationTypes.Time(dateTime);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new ApplicationTypes.DeviceId(ref arr, ref idx);
Time = new ApplicationTypes.Time(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
Time.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" - ");
Time.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,82 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance
{
public class AuditTrailNotification : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.AuditTrailNotification;
public PacketSequenceNumber PacketSequence { get; set; } = new();
private static uint Reserved => 0;
public Enumerations.AuditTrailMessageType MessageType { get; set; }
public TimeStamp TimeStamp { get; set; } = new();
public Enumerations.AccessDecision AccessDecision { get; set; }
public List<CredentialBlock> Credential { get; } = [];
public AuditTrailNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
PacketSequence = new PacketSequenceNumber(ref arr, ref idx);
idx += 1; //reserved enum
MessageType = (Enumerations.AuditTrailMessageType)PrimitiveType.DeserializeEnum(ref arr, ref idx);
TimeStamp = new TimeStamp(ref arr, ref idx);
AccessDecision = (Enumerations.AccessDecision)PrimitiveType.DeserializeEnum(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
//Credential = [];
for (int i = 1; i <= arrlen.Value; i++)
{
CredentialBlock cred = new(ref arr, ref idx);
Credential.Add(cred);
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
PacketSequence.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Reserved));
arr.AddRange(PrimitiveType.SerializeEnum((short)MessageType));
TimeStamp.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)AccessDecision));
if (Credential != null)
{
new VariableLengthQuantity((uint)Credential.Count).Serialize(ref arr);
foreach (var cred in Credential)
{
cred.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
PacketSequence.LogString(ref sb);
sb.Append(" MessageType = " + MessageType.ToString());
TimeStamp.LogString(ref sb);
sb.Append(" AccessDescision = " + AccessDecision.ToString());
if (Credential != null)
{
sb.Append(Environment.NewLine);
foreach (var cred in Credential)
{
cred.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,53 @@
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance
{
public class ClearDtcCommand : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.ClearDtcCommand;
public VariableLengthQuantity DTCId { get; set; } = new();
public ClearDtcCommand() { }
public ClearDtcCommand(byte[] devid, uint id)
{
Device = new DeviceId(devid);
DTCId = new VariableLengthQuantity(id);
}
public ClearDtcCommand(DeviceId devid, uint id)
{
Device = devid;
DTCId = new VariableLengthQuantity(id);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
DTCId = new VariableLengthQuantity(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
DTCId.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" DTCid-'");
DTCId.LogString(ref sb);
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,51 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance
{
public class ClearDtcResult : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.ClearDtcResult;
public Enumerations.Status Result { get; set; }
public ClearDtcResult() { }
public ClearDtcResult(string devId, Enumerations.Status result)
{
Device = new DeviceId(devId);
Result = result;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
Result = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Result));
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" Result-'");
sb.Append(Result.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,62 @@
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance
{
public class DeviceListResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DeviceListResult;
public List<DeviceDefinition> Devices { get; } = [];
public DeviceListResult() { }
public DeviceListResult(List<DeviceDefinition> devices)
{
Devices = devices;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
VariableLengthQuantity arrlen = new(ref arr, ref idx);
//Devices = [];
for (int i = 1; i <= arrlen.Value; i++)
{
Devices.Add(new DeviceDefinition(ref arr, ref idx));
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
if (Devices != null)
{
new VariableLengthQuantity((uint)Devices.Count).Serialize(ref arr);
foreach (DeviceDefinition device in Devices)
{
device.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
sb.Append(Environment.NewLine);
if (Devices != null)
{
foreach (DeviceDefinition dev in Devices)
{
dev.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,43 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance
{
public class DtcNotification : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.DtcNotification;
public DtcInfo DTC { get; set; } = new();
public DtcNotification() { }
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
DTC = new DtcInfo(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
DTC.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" - ");
DTC.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,70 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance
{
public class GetAuditTrailCommand : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetAuditTrailCommand;
public PacketSequenceNumber SequenceNumber { get; set; } = new();
private static uint Reserved => 0;
public Enumerations.ReadSequence ReadSequence { get; set; }
public GetAuditTrailCommand() { }
public GetAuditTrailCommand(byte[] id, Enumerations.ReadSequence sequence)
{
Device = new DeviceId(id);
SequenceNumber = new PacketSequenceNumber();
ReadSequence = sequence;
}
public GetAuditTrailCommand(DeviceId id, Enumerations.ReadSequence sequence, ushort sequenceNumber)
{
Device = id;
SequenceNumber = new PacketSequenceNumber(sequenceNumber);
ReadSequence = sequence;
}
public GetAuditTrailCommand(DeviceId id, Enumerations.ReadSequence sequence)
{
Device = id;
SequenceNumber = new PacketSequenceNumber();
ReadSequence = sequence;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
SequenceNumber = new PacketSequenceNumber(ref arr, ref idx);
idx += 1; //reserved enum
ReadSequence = (Enumerations.ReadSequence)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
SequenceNumber.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Reserved));
arr.AddRange(PrimitiveType.SerializeEnum((short)ReadSequence));
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
SequenceNumber.LogString(ref sb);
sb.Append(" Readsequence-'");
sb.Append(ReadSequence.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,50 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance
{
public class GetAuditTrailResult : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetAuditTrailResult;
public Enumerations.Status Result { get; set; }
public GetAuditTrailResult() { }
public GetAuditTrailResult(string devId, Enumerations.Status result)
{
Device = new DeviceId(devId);
Result = result;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
Result = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Result));
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" Result-'");
sb.Append(Result.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,30 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
namespace Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance
{
public class GetDeviceListCommand : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetDeviceListCommand;
public GetDeviceListCommand() { }
public void Deserialize(ref byte[] arr, ref int idx) { }
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
}
public string LogString()
{
return string.Empty;
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,75 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance
{
public class GetDtcStatusCommand : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetDtcStatusCommand;
public Enumerations.DtcSelection Selection { get; set; }
public VariableLengthQuantity MaxDtcs { get; set; } = new();
public VariableLengthQuantity Index { get; set; } = new();
public GetDtcStatusCommand() { }
public GetDtcStatusCommand(byte[] devid, uint max, uint idx)
{
Device = new DeviceId(devid);
Selection = Enumerations.DtcSelection.ALL;
MaxDtcs = new VariableLengthQuantity(max);
Index = new VariableLengthQuantity(idx);
}
public GetDtcStatusCommand(DeviceId devid, uint max, uint idx)
{
Device = devid;
Selection = Enumerations.DtcSelection.ALL;
MaxDtcs = new VariableLengthQuantity(max);
Index = new VariableLengthQuantity(idx);
}
public GetDtcStatusCommand(DeviceId devid, uint max, uint idx, Enumerations.DtcSelection selection)
{
Device = devid;
Selection = selection;
MaxDtcs = new VariableLengthQuantity(max);
Index = new VariableLengthQuantity(idx);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
Selection = (Enumerations.DtcSelection)PrimitiveType.DeserializeEnum(ref arr, ref idx);
MaxDtcs = new VariableLengthQuantity(ref arr, ref idx);
Index = new VariableLengthQuantity(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Selection));
MaxDtcs.Serialize(ref arr);
Index.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" - ");
sb.Append(Selection.ToString());
sb.Append(" - ");
MaxDtcs.LogString(ref sb);
sb.Append(" - ");
Index.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,68 @@
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance
{
public class GetDtcStatusResult : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetDtcStatusResult;
public List<DtcInfo> DTCs { get; } = [];
public GetDtcStatusResult() { }
public GetDtcStatusResult(string devId, List<DtcInfo> dtcInfos)
{
Device = new DeviceId(devId);
DTCs = dtcInfos;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
//DTCs = [];
for (int i = 1; i <= arrlen.Value; i++)
{
DtcInfo dtcInfo = new(ref arr, ref idx);
DTCs.Add(dtcInfo);
}
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
if (DTCs != null)
{
new VariableLengthQuantity((uint)DTCs.Count).Serialize(ref arr);
foreach (DtcInfo dtc in DTCs)
{
dtc.Serialize(ref arr);
}
}
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
if (DTCs != null)
{
sb.Append(Environment.NewLine);
foreach (DtcInfo dtc in DTCs)
{
dtc.LogString(ref sb);
sb.Append(Environment.NewLine);
}
}
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,87 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance
{
public class GetTimeCommand : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetTimeCommand;
public GetTimeCommand() { }
public GetTimeCommand(byte[] device)
{
Device = new DeviceId(device);
}
public GetTimeCommand(DeviceId device)
{
Device = device;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
public class GetTimeResult : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.GetTimeResult;
public Time Time { get; set; } = new();
public GetTimeResult() { }
public GetTimeResult(string devId, DateTime dateTime)
{
Device = new DeviceId(devId);
Time = new Time(dateTime);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
Time = new Time(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
Time.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" - ");
Time.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,53 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance
{
public class SetTimeCommand : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.SetTimeCommand;
public Time Time { get; set; } = new();
public SetTimeCommand() { }
public SetTimeCommand(byte[] device, DateTime dateTime)
{
Device = new DeviceId(device);
Time = new Time(dateTime);
}
public SetTimeCommand(DeviceId device, DateTime dateTime)
{
Device = device;
Time = new Time(dateTime);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
Time = new Time(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
Time.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" - ");
Time.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,50 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance
{
public class SetTimeResult : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.SetTimeResult;
public Enumerations.Status Result { get; set; }
public SetTimeResult() { }
public SetTimeResult(string devId, Enumerations.Status result)
{
Device = new DeviceId(devId);
Result = result;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
Result = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Result));
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" Result-'");
sb.Append(Result.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,46 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance
{
public class StatusRequest : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.StatusRequest;
public Enumerations.Status Status { get; set; }
public StatusRequest() { }
public StatusRequest(Enumerations.Status state)
{
Status = state;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Status = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Status));
}
public string LogString()
{
StringBuilder sb = new();
sb.Append("Status-'");
sb.Append(Status.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,46 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance
{
public class StatusResponse : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.StatusResponse;
public Enumerations.Status Status { get; set; }
public StatusResponse() { }
public StatusResponse(Enumerations.Status state)
{
Status = state;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Status = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Status));
}
public string LogString()
{
StringBuilder sb = new();
sb.Append("Status-'");
sb.Append(Status.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,48 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance
{
public class TimeNotification : CommandDeviceIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.TimeNotification;
public Time Time { get; set; } = new();
public TimeNotification() { }
public TimeNotification(string devid, DateTime dateTime)
{
Device = new DeviceId(devid);
Time = new Time(dateTime);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
Device = new DeviceId(ref arr, ref idx);
Time = new Time(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
Device.Serialize(ref arr);
Time.Serialize(ref arr);
}
public string LogString()
{
StringBuilder sb = new();
Device.LogString(ref sb);
sb.Append(" Time = ");
Time.LogString(ref sb);
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -1,20 +1,21 @@
using System.Text;
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp
namespace Aperio_Control_Centre.Aadp.Commands.OutputToUser
{
public class IndicationCommand : IPduCommand
public class IndicationCommand : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.IndicationCommand;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public Enumerations.DoorSide DoorSide { get; set; }
public List<Enumerations.Indication> Indications { get; } = [];
public ApplicationTypes.Timing IndicationTime { get; set; } = new();
public Timing IndicationTime { get; set; } = new();
public IndicationCommand() { }
public IndicationCommand(string devid, Enumerations.DoorSide doorside, Enumerations.Indication indication, uint time, Enumerations.TimingMode mode)
{
DeviceGroupId = new ApplicationTypes.Id(devid);
DeviceGroupId = new Id(devid);
DoorSide = doorside;
//TODO: use a List of indications
@@ -23,12 +24,12 @@ namespace Aperio_Control_Centre.Aadp
indication
];
IndicationTime = new ApplicationTypes.Timing(time, mode);
IndicationTime = new Timing(time, mode);
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
DeviceGroupId = new Id(ref arr, ref idx);
DoorSide = (Enumerations.DoorSide)PrimitiveType.DeserializeEnum(ref arr, ref idx);
VariableLengthQuantity arrlen = new(ref arr, ref idx);
@@ -38,7 +39,7 @@ namespace Aperio_Control_Centre.Aadp
Indications.Add((Enumerations.Indication)PrimitiveType.DeserializeEnum(ref arr, ref idx));
}
IndicationTime = new ApplicationTypes.Timing(ref arr, ref idx);
IndicationTime = new Timing(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
@@ -46,13 +47,13 @@ namespace Aperio_Control_Centre.Aadp
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)DoorSide));
arr.AddRange(PrimitiveType.SerializeEnum((short)DoorSide));
if (Indications != null)
{
new VariableLengthQuantity((uint)Indications.Count).Serialize(ref arr);
foreach (var indication in Indications)
{
arr.AddRange(PrimitiveType.SerializeEnum((Int16)indication));
arr.AddRange(PrimitiveType.SerializeEnum((short)indication));
}
}
IndicationTime.Serialize(ref arr);
@@ -87,48 +88,4 @@ namespace Aperio_Control_Centre.Aadp
return PDUType.ToString();
}
}
public class IndicationResult : IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.IndicationResult;
public ApplicationTypes.Id DeviceGroupId { get; set; } = new();
public Enumerations.Status Result { get; set; }
public IndicationResult() { }
public IndicationResult(String devid, Enumerations.Status result)
{
DeviceGroupId = new ApplicationTypes.Id(devid);
Result = result;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new ApplicationTypes.Id(ref arr, ref idx);
Result = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((Int16)Result));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Result-'");
sb.Append(Result.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,49 @@
using Aperio_Control_Centre.Aadp.Types;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
using System.Text;
namespace Aperio_Control_Centre.Aadp.Commands.OutputToUser
{
public class IndicationResult : CommandIdBase, IPduCommand
{
public Enumerations.PDUTypes PDUType => Enumerations.PDUTypes.IndicationResult;
public Enumerations.Status Result { get; set; }
public IndicationResult() { }
public IndicationResult(string devid, Enumerations.Status result)
{
DeviceGroupId = new Id(devid);
Result = result;
}
public void Deserialize(ref byte[] arr, ref int idx)
{
DeviceGroupId = new Id(ref arr, ref idx);
Result = (Enumerations.Status)PrimitiveType.DeserializeEnum(ref arr, ref idx);
}
public void Serialize(ref List<byte> arr)
{
ArgumentNullException.ThrowIfNull(arr);
new VariableLengthQuantity((uint)PDUType).Serialize(ref arr);
DeviceGroupId.Serialize(ref arr);
arr.AddRange(PrimitiveType.SerializeEnum((short)Result));
}
public string LogString()
{
StringBuilder sb = new();
DeviceGroupId.LogString(ref sb);
sb.Append(" Result-'");
sb.Append(Result.ToString());
sb.Append('\'');
return sb.ToString();
}
public override string ToString()
{
return PDUType.ToString();
}
}
}

View File

@@ -0,0 +1,83 @@
using Aperio_Control_Centre.Aadp.Commands.Configuration;
using Aperio_Control_Centre.Aadp.Commands.DeviceStates;
using Aperio_Control_Centre.Aadp.Commands.DoorControl;
using Aperio_Control_Centre.Aadp.Commands.InputFromUser;
using Aperio_Control_Centre.Aadp.Commands.OperationAndMaintenance;
using Aperio_Control_Centre.Aadp.Commands.OutputToUser;
using Aperio_Control_Centre.Aadp.Types.ApplicationTypes;
namespace Aperio_Control_Centre.Aadp.Commands
{
public static class PduMessageInvoker
{
public static IPduCommand GetMessage(VariableLengthQuantity messageType)
{
return (Enumerations.PDUTypes)messageType.Value switch
{
Enumerations.PDUTypes.HelloRequest => new HelloRequest(),
Enumerations.PDUTypes.HelloResponse => new HelloResponse(),
Enumerations.PDUTypes.DeviceGroupInfoNotification => new DeviceGroupInfoNotification(),
Enumerations.PDUTypes.CredentialNotification => new CredentialNotification(),
Enumerations.PDUTypes.KeypadNotification => new KeypadNotification(),
Enumerations.PDUTypes.RestartCommand => new RestartCommand(),
Enumerations.PDUTypes.IndicationCommand => new IndicationCommand(),
Enumerations.PDUTypes.IndicationResult => new IndicationResult(),
Enumerations.PDUTypes.GetSupportedDoorModesCommand => new GetSupportedDoorModesCommand(),
Enumerations.PDUTypes.GetSupportedDoorModesResult => new GetSupportedDoorModesResult(),
Enumerations.PDUTypes.DoorOpeningCommand => new DoorOpeningCommand(),
Enumerations.PDUTypes.DoorOpeningResult => new DoorOpeningResult(),
Enumerations.PDUTypes.SetDoorModeCommand => new SetDoorModeCommand(),
Enumerations.PDUTypes.SetDoorModeResult => new SetDoorModeResult(),
Enumerations.PDUTypes.StatusRequest => new StatusRequest(),
Enumerations.PDUTypes.StatusResponse => new StatusResponse(),
Enumerations.PDUTypes.GetDeviceParameterCommand => new GetDeviceParameterCommand(),
Enumerations.PDUTypes.GetDeviceParameterResult => new GetDeviceParameterResult(),
Enumerations.PDUTypes.DtcNotification => new DtcNotification(),
Enumerations.PDUTypes.GetDtcStatusCommand => new GetDtcStatusCommand(),
Enumerations.PDUTypes.GetDtcStatusResult => new GetDtcStatusResult(),
Enumerations.PDUTypes.ClearDtcCommand => new ClearDtcCommand(),
Enumerations.PDUTypes.ClearDtcResult => new ClearDtcResult(),
Enumerations.PDUTypes.GetDeviceListCommand => new GetDeviceListCommand(),
Enumerations.PDUTypes.DeviceListResult => new DeviceListResult(),
Enumerations.PDUTypes.GetAuditTrailCommand => new GetAuditTrailCommand(),
Enumerations.PDUTypes.GetAuditTrailResult => new GetAuditTrailResult(),
Enumerations.PDUTypes.AuditTrailNotification => new AuditTrailNotification(),
Enumerations.PDUTypes.TimeNotification => new TimeNotification(),
Enumerations.PDUTypes.SetTimeCommand => new SetTimeCommand(),
Enumerations.PDUTypes.SetTimeResult => new SetTimeResult(),
Enumerations.PDUTypes.GetTimeCommand => new GetTimeCommand(),
Enumerations.PDUTypes.GetTimeResult => new GetTimeResult(),
Enumerations.PDUTypes.SetDeviceParameterCommand => new SetDeviceParameterCommand(),
Enumerations.PDUTypes.SetDeviceParameterResult => new SetDeviceParameterResult(),
Enumerations.PDUTypes.DeviceParameterNotification => new DeviceParameterNotification(),
Enumerations.PDUTypes.SetCredentialCommand => new SetCredentialCommand(),
Enumerations.PDUTypes.SetCredentialResult => new SetCredentialResult(),
Enumerations.PDUTypes.DeleteCredentialCommand => new DeleteCredentialCommand(),
Enumerations.PDUTypes.DeleteCredentialResult => new DeleteCredentialResult(),
Enumerations.PDUTypes.CredentialManagementNotification => new CredentialManagementNotification(),
Enumerations.PDUTypes.GetDoorStateCommand => new GetDoorStateCommand(),
Enumerations.PDUTypes.DoorStateResult => new DoorStateResult(),
Enumerations.PDUTypes.DoorStateNotification => new DoorStateNotification(),
Enumerations.PDUTypes.GetLockStateCommand => new GetLockStateCommand(),
Enumerations.PDUTypes.LockStateResult => new LockStateResult(),
Enumerations.PDUTypes.LockStateNotification => new LockStateNotification(),
Enumerations.PDUTypes.GetKeyCylinderStateCommand => new GetKeyCylinderStateCommand(),
Enumerations.PDUTypes.KeyCylinderStateResult => new KeyCylinderStateResult(),
Enumerations.PDUTypes.KeyCylinderStateNotification => new KeyCylinderStateNotification(),
Enumerations.PDUTypes.GetHandleStateCommand => new GetHandleStateCommand(),
Enumerations.PDUTypes.HandleStateResult => new HandleStateResult(),
Enumerations.PDUTypes.HandleStateNotification => new HandleStateNotification(),
Enumerations.PDUTypes.GetTamperStateCommand => new GetTamperStateCommand(),
Enumerations.PDUTypes.TamperStateResult => new TamperStateResult(),
Enumerations.PDUTypes.TamperStateNotification => new TamperStateNotification(),
Enumerations.PDUTypes.GetActivatorStateCommand => new GetActivatorStateCommand(),
Enumerations.PDUTypes.ActivatorStateResult => new ActivatorStateResult(),
Enumerations.PDUTypes.ActivatorStateNotification => new ActivatorStateNotification(),
Enumerations.PDUTypes.GetDoorModeCommand => new GetDoorModeCommand(),
Enumerations.PDUTypes.GetDoorModeResult => new GetDoorModeResult(),
Enumerations.PDUTypes.DoorModeNotification => new DoorModeNotification(),
_ => new CommandError("Unknown PDU Type"),
};
}
}
}

View File

@@ -0,0 +1,12 @@
namespace Aperio_Control_Centre.Aadp.Enumerations
{
public enum AccessDecision : int
{
DENIED = 0,
GRANTED = 1,
RESERVED = 2,
RESERVED1 = 3,
ANOTHER_CREDENTIAL_REQUESTED = 4,
NOT_APPLICABLE = 127
}
}

View File

@@ -0,0 +1,13 @@
namespace Aperio_Control_Centre.Aadp.Enumerations
{
public enum ActivatorState : int
{
UNKNOWN = 0,
NOT_USED = 1,
INSIDE_USED = 2,
OUTSIDE_USED = 3,
BOTH_USED = 4,
UNKNOWN_SIDE_USED = 5,
USED = 6
}
}

View File

@@ -0,0 +1,12 @@
namespace Aperio_Control_Centre.Aadp.Enumerations
{
public enum AuditTrailMessageType : int
{
RESERVED = 0,
NACK = 1,
AUDIT_TRAIL_ITEM = 2,
AUDIT_TRAIL_IS_EMPTY = 3,
AUDIT_TRAIL_ITEMS_ADDED = 4,
AUDIT_TRAIL_ITEMS_OVERWRITTEN = 5,
}
}

View File

@@ -0,0 +1,19 @@
namespace Aperio_Control_Centre.Aadp.Enumerations
{
public enum CredentialBlockType : int
{
Unknown = 0x0000,
Custom = 0x0010,
SourceDetails = 0x0100,
MIFAREUID = 0x0200,
DynamicData = 0x0201,
iCLASSAccessId = 0x0300,
ISO14443BUID = 0x0400,
ISO15693UID = 0x0500,
LegicUID = 0x0600,
SIO = 0x0700,
PIN = 0x0800,
PICOPASS_SERIAL_NUMBER = 0x900,
STID_DATA = 0x0A00,
}
}

View File

@@ -0,0 +1,11 @@
namespace Aperio_Control_Centre.Aadp.Enumerations
{
public enum CredentialDeleteMode : int
{
RESERVED = 0,
DELETE_ALL_DYNAMIC = 1,
DELETE_ALL_STATIC = 2,
DELETE_ALL_DYNAMIC_AND_STATIC = 3,
DELETE_SINGLE = 4,
}
}

View File

@@ -0,0 +1,16 @@
namespace Aperio_Control_Centre.Aadp.Enumerations
{
[Flags]
public enum CredentialManagementNotificationType : int
{
RESERVED = 0x00,
CREDENTIAL_ADDED = 0x01,
SINGLE_CREDENTIAL_DELETED = 0x02,
ALL_CREDENTIALS_DELETED = 0x03,
ALL_DYNAMIC_CREDENTIALS_DELETED = 0x04,
ALL_STATIC_CREDENTIALS_DELETED = 0x05,
CREDENTIAL_DATABASE_UPDATED = 0x06,
FAIL = 0x80,
FAILED_STORAGE_FULL = 0x81
}
}

Some files were not shown because too many files have changed in this diff Show More