OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
ReaderLedControl.cs
1using System;
2using System.Collections.Generic;
3
5
7
11public class ReaderLedControl
12{
30 byte readerNumber,
31 byte ledNumber,
32 TemporaryReaderControlCode temporaryMode,
33 byte temporaryOnTime,
34 byte temporaryOffTime,
35 LedColor temporaryOnColor,
36 LedColor temporaryOffColor,
37 ushort temporaryTimer,
38 PermanentReaderControlCode permanentMode,
39 byte permanentOnTime,
40 byte permanentOffTime,
41 LedColor permanentOnColor,
42 LedColor permanentOffColor)
43 {
44 ReaderNumber = readerNumber;
45 LedNumber = ledNumber;
46 TemporaryMode = temporaryMode;
47 TemporaryOnTime = temporaryOnTime;
48 TemporaryOffTime = temporaryOffTime;
49 TemporaryOnColor = temporaryOnColor;
50 TemporaryOffColor = temporaryOffColor;
51 TemporaryTimer = temporaryTimer;
52 PermanentMode = permanentMode;
53 PermanentOnTime = permanentOnTime;
54 PermanentOffTime = permanentOffTime;
55 PermanentOnColor = permanentOnColor;
56 PermanentOffColor = permanentOffColor;
57 }
58
60 public byte ReaderNumber { get; }
61
65 public byte LedNumber { get; }
66
71
75 public byte TemporaryOnTime { get; }
76
80 public byte TemporaryOffTime { get; }
81
85 public LedColor TemporaryOnColor { get; }
86
91
95 public ushort TemporaryTimer { get; }
96
101
105 public byte PermanentOnTime { get; }
106
110 public byte PermanentOffTime { get; }
111
116
121
122 internal IEnumerable<byte> BuildData()
123 {
124 var temporaryTimerBytes = Message.ConvertShortToBytes(TemporaryTimer);
125
126 return new[]
127 {
129 LedNumber,
130 (byte) TemporaryMode,
133 (byte) TemporaryOnColor,
134 (byte) TemporaryOffColor,
135 temporaryTimerBytes[0],
136 temporaryTimerBytes[1],
137 (byte) PermanentMode,
140 (byte) PermanentOnColor,
141 (byte) PermanentOffColor
142 };
143 }
144
148 public static ReaderLedControl ParseData(ReadOnlySpan<byte> data)
149 {
150 return new ReaderLedControl(
151 data[0],
152 data[1],
154 data[3],
155 data[4],
156 (LedColor)data[5],
157 (LedColor)data[6],
158 Message.ConvertBytesToUnsignedShort(data.Slice(7, 2)),
160 data[10],
161 data[11],
162 (LedColor)data[12],
163 (LedColor)data[13]);
164 }
165}
166
187
192{
196 Nop = 0x00,
197
202}
203
207public enum LedColor
208{
209#pragma warning disable CS1591
210 Black = 0,
211 Red = 1,
212 Green = 2,
213 Amber = 3,
214 Blue = 4,
215 Magenta = 5,
216 Cyan = 6,
217 White = 7
218#pragma warning restore CS1591
219}
A base message class for sending or replying.
Definition Message.cs:12
ReaderLedControl(byte readerNumber, byte ledNumber, TemporaryReaderControlCode temporaryMode, byte temporaryOnTime, byte temporaryOffTime, LedColor temporaryOnColor, LedColor temporaryOffColor, ushort temporaryTimer, PermanentReaderControlCode permanentMode, byte permanentOnTime, byte permanentOffTime, LedColor permanentOnColor, LedColor permanentOffColor)
Initializes a new instance of the ReaderLedControl class.
byte TemporaryOffTime
Gets the temporary off time in units of 100ms.
static ReaderLedControl ParseData(ReadOnlySpan< byte > data)
Parses the message payload bytes.
byte ReaderNumber
Gets the reader number starting at 0.
LedColor TemporaryOffColor
Gets the color of the temporary off.
PermanentReaderControlCode PermanentMode
Gets the permanent mode.
LedColor PermanentOffColor
Gets the color of the permanent off.
TemporaryReaderControlCode TemporaryMode
Gets the temporary mode.
LedColor TemporaryOnColor
Gets the color of the temporary on.
byte TemporaryOnTime
Gets the temporary on time in units of 100ms.
LedColor PermanentOnColor
Gets the color of the permanent on.
byte PermanentOffTime
Gets the permanent off time in units of 100ms.
ushort TemporaryTimer
Gets the temporary timer in units of 100ms.
byte PermanentOnTime
Gets the permanent on time in units of 100ms.
PermanentReaderControlCode
Permanent control code values.
@ SetPermanentState
Set the permanent state as given.
@ Nop
NOP – do not alter this output.
TemporaryReaderControlCode
Temporary control code values.
@ SetTemporaryAndStartTimer
Set the temporary state as given and start timer immediately.
@ CancelAnyTemporaryAndDisplayPermanent
Cancel any temporary operation and display this LED's permanent state immediately.