OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
ReaderTextOutput.cs
1using System;
2using System.Collections.Generic;
3using System.Text;
6
8{
13 {
23 public ReaderTextOutput(byte readerNumber, TextCommand textCommand, byte temporaryTextTime, byte row, byte column, string text)
24 {
25 ReaderNumber = readerNumber;
26 TextCommand = textCommand;
27 TemporaryTextTime = temporaryTextTime;
28 Row = row;
29 Column = column;
30 Text = text;
31 }
32
36 public byte ReaderNumber { get; }
37
41 public TextCommand TextCommand { get; }
42
46 public byte TemporaryTextTime { get; }
47
49 public byte Row { get; }
50
52 public byte Column { get; }
53
57 public string Text { get; }
58
62 public static ReaderTextOutput ParseData(ReadOnlySpan<byte> data)
63 {
64 string text = Encoding.ASCII.GetString(data.Slice(6).ToArray());
65 return new ReaderTextOutput(data[0], (TextCommand)data[1], data[2], data[3], data[4], text);
66 }
67
69 public override CommandType CommandType => CommandType.TextOutput;
70
72 public override byte Code => (byte)CommandType;
73
75 public override ReadOnlySpan<byte> SecurityControlBlock()
76 {
77 return SecurityBlock.CommandMessageWithDataSecurity;
78 }
79
81 public override byte[] BuildData()
82 {
83 var data = new List<byte>
84 {ReaderNumber, (byte) TextCommand, TemporaryTextTime, Row, Column, (byte) Text.Length};
85 data.AddRange(Encoding.ASCII.GetBytes(Text.Substring(0, Math.Min(Text.Length, byte.MaxValue))));
86 return data.ToArray();
87 }
88
90 public override string ToString()
91 {
92 var sb = new StringBuilder();
93 sb.AppendLine($" Reader Number: {ReaderNumber}");
94 sb.AppendLine($" Text Command: {TextCommand}");
95 sb.AppendLine($"Temp Text Time: {TemporaryTextTime}");
96 sb.AppendLine($" Row, Column: {Row}, {Column}");
97 sb.AppendLine($" Display Text: {Text}");
98 return sb.ToString();
99 }
100 }
101
127}
Contains standard Security Control Block data that can be used when building messages.
Base class representing a payload of a PD command message.
TextCommand TextCommand
Gets the text command for displaying.
byte ReaderNumber
Gets the reader number starting at 0.
byte Row
Gets the row where the first character will be displayed. 0x01 = top row.
byte Column
The column where the first character will be displayed 0x01 = leftmost column.
static ReaderTextOutput ParseData(ReadOnlySpan< byte > data)
Parses the message payload bytes.
override ReadOnlySpan< byte > SecurityControlBlock()
ReaderTextOutput(byte readerNumber, TextCommand textCommand, byte temporaryTextTime, byte row, byte column, string text)
Initializes a new instance of the ReaderTextOutput class.
string Text
Gets the text to display.
byte TemporaryTextTime
Gets the temporary text time in units of 100ms.
TextCommand
Text command for displaying values.
@ TemporaryTextNoWrap
Display text temporarily with no wrap.
@ TemporaryTextWithWrap
Display text temporarily with wrap.
@ PermanentTextNoWrap
Display text permanently with no wrap.
@ PermanentTextWithWrap
Display text permanently with wrap.