OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
CommandReplyExtensions.cs
1using System.Collections.Generic;
2
4
8public static class CommandReplyExtensions
9{
10 private static readonly Dictionary<CommandType, string> CommandDisplayNames = new()
11 {
12 { CommandType.Poll, "osdp_POLL" },
13 { CommandType.IdReport, "osdp_ID" },
14 { CommandType.DeviceCapabilities, "osdp_CAP" },
15 { CommandType.LocalStatus, "osdp_LSTAT" },
16 { CommandType.InputStatus, "osdp_ISTAT" },
17 { CommandType.OutputStatus, "osdp_OSTAT" },
18 { CommandType.ReaderStatus, "osdp_RSTAT" },
19 { CommandType.OutputControl, "osdp_OUT" },
20 { CommandType.LEDControl, "osdp_LED" },
21 { CommandType.BuzzerControl, "osdp_BUZ" },
22 { CommandType.TextOutput, "osdp_TEXT" },
23 { CommandType.CommunicationSet, "osdp_COMSET" },
24 { CommandType.BioRead, "osdp_BIOREAD" },
25 { CommandType.BioMatch, "osdp_BIOMATCH" },
26 { CommandType.KeySet, "osdp_KEYSET" },
27 { CommandType.SessionChallenge, "osdp_CHLNG" },
28 { CommandType.ServerCryptogram, "osdp_SCRYPT" },
29 { CommandType.MaxReplySize, "osdp_ACURXSIZE" },
30 { CommandType.FileTransfer, "osdp_FILETRANSFER" },
31 { CommandType.ManufacturerSpecific, "osdp_MFG" },
32 { CommandType.ExtendedWrite, "osdp_XWR" },
33 { CommandType.Abort, "osdp_ABORT" },
34 { CommandType.PivData, "osdp_PIVDATA" },
35 { CommandType.GenerateChallenge, "osdp_GENAUTH" },
36 { CommandType.AuthenticateChallenge, "osdp_CRAUTH" },
37 { CommandType.KeepActive, "osdp_KEEPACTIVE" }
38 };
39
40 private static readonly Dictionary<ReplyType, string> ReplyDisplayNames = new()
41 {
42 { ReplyType.Ack, "osdp_ACK" },
43 { ReplyType.Nak, "osdp_NAK" },
44 { ReplyType.PdIdReport, "osdp_PDID" },
45 { ReplyType.PdCapabilitiesReport, "osdp_PDCAP" },
46 { ReplyType.LocalStatusReport, "osdp_LSTATR" },
47 { ReplyType.InputStatusReport, "osdp_ISTATR" },
48 { ReplyType.OutputStatusReport, "osdp_OSTATR" },
49 { ReplyType.ReaderStatusReport, "osdp_RSTATR" },
50 { ReplyType.RawReaderData, "osdp_RAW" },
51 { ReplyType.FormattedReaderData, "osdp_FMT" },
52 { ReplyType.KeypadData, "osdp_KEYPAD" },
53 { ReplyType.PdCommunicationsConfigurationReport, "osdp_COM" },
54 { ReplyType.BiometricData, "osdp_BIOREADR" },
55 { ReplyType.BiometricMatchResult, "osdp_BIOMATCHR" },
56 { ReplyType.ExtendedPdIdReport, "osdp_EXT_PDID" },
57 { ReplyType.CrypticData, "osdp_CCRYPT" },
58 { ReplyType.InitialRMac, "osdp_RMAC_I" },
59 { ReplyType.Busy, "osdp_BUSY" },
60 { ReplyType.FileTransferStatus, "osdp_FTSTAT" },
61 { ReplyType.PIVData, "osdp_PIVDATAR" },
62 { ReplyType.ResponseToChallenge, "osdp_CRAUTHR" },
63 { ReplyType.ManufactureSpecific, "osdp_MFGREP" },
64 { ReplyType.ExtendedRead, "osdp_XRD" }
65 };
66
75 public static string GetDisplayName(this CommandType commandType)
76 {
77 return CommandDisplayNames.TryGetValue(commandType, out var name)
78 ? name
79 : commandType.ToString();
80 }
81
90 public static string GetDisplayName(this ReplyType replyType)
91 {
92 return ReplyDisplayNames.TryGetValue(replyType, out var name)
93 ? name
94 : replyType.ToString();
95 }
96}
Extension methods for CommandType and ReplyType enums.
static string GetDisplayName(this ReplyType replyType)
Gets the OSDP protocol name for the reply type.
static string GetDisplayName(this CommandType commandType)
Gets the OSDP protocol name for the command type.
ReplyType
Identifies the type of OSDP protocol reply (PD -> ACU) message.
Definition ReplyType.cs:7
CommandType
Identifies the type of OSDP protocol command (ACU -> PD) message.
Definition CommandType.cs:7