OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
ReaderBuzzerControl.cs
1using System;
2using System.Text;
5
7
12{
21 public ReaderBuzzerControl(byte readerNumber, ToneCode toneCode, byte onTime, byte offTime, byte count)
22 {
23 ReaderNumber = readerNumber;
24 ToneCode = toneCode;
25 OnTime = onTime;
26 OffTime = offTime;
27 Count = count;
28 }
29
33 public byte ReaderNumber { get; }
34
38 public ToneCode ToneCode { get; }
39
43 public byte OnTime { get; }
44
48 public byte OffTime { get; }
49
53 public byte Count { get; }
54
58 public static ReaderBuzzerControl ParseData(ReadOnlySpan<byte> data)
59 {
60 return new ReaderBuzzerControl(
61 data[0],
62 (ToneCode)data[1],
63 data[2],
64 data[3],
65 data[4]);
66 }
67
68
70 public override CommandType CommandType => CommandType.BuzzerControl;
71
73 public override byte Code => (byte)CommandType;
74
76 public override ReadOnlySpan<byte> SecurityControlBlock() => SecurityBlock.CommandMessageWithDataSecurity;
77
79 public override byte[] BuildData()
80 {
81 return [ReaderNumber, (byte) ToneCode, OnTime, OffTime, Count];
82 }
83
85 public override string ToString()
86 {
87 var sb = new StringBuilder();
88 sb.AppendLine($" Reader #: {ReaderNumber}");
89 sb.AppendLine($"Tone Code: {ToneCode}");
90 sb.AppendLine($" On Time: {OnTime}");
91 sb.AppendLine($" Off Time: {OffTime}");
92 sb.AppendLine($" Count: {Count}");
93 return sb.ToString();
94 }
95}
96
100public enum ToneCode
101{
102 [Obsolete("This no tone code is obsolete.", false)]
103#pragma warning disable CS1591
104 None = 0x00,
105#pragma warning restore CS1591
106
110 Off = 0x01,
111
115 Default = 0x02
116}
Contains standard Security Control Block data that can be used when building messages.
Base class representing a payload of a PD command message.
byte OffTime
Gets the off time in units of 100ms.
byte ReaderNumber
Gets the reader number starting at 0.
byte Count
Gets the number of times to repeat the on/off cycle.
override ReadOnlySpan< byte > SecurityControlBlock()
ReaderBuzzerControl(byte readerNumber, ToneCode toneCode, byte onTime, byte offTime, byte count)
Initializes a new instance of the ReaderBuzzerControl class.
static ReaderBuzzerControl ParseData(ReadOnlySpan< byte > data)
Parses the message payload bytes.
byte OnTime
Gets the on time in units of 100ms.