OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
InputStatus.cs
3using System;
4using System.Linq;
5using System.Text;
6
8{
12 public class InputStatus : PayloadData
13 {
18 public InputStatus(InputStatusValue[] statuses)
19 {
20 InputStatuses = statuses ?? throw new ArgumentNullException(nameof(statuses));
21 }
22
27 [Obsolete("Use the constructor accepting InputStatusValue[] instead. This constructor will be removed in a future version.")]
28 public InputStatus(bool[] statuses)
29 {
30 if (statuses == null) throw new ArgumentNullException(nameof(statuses));
31 InputStatuses = statuses.Select(x => x ? InputStatusValue.Active : InputStatusValue.Inactive).ToArray();
32 }
33
35 public override byte Code => (byte)ReplyType.InputStatusReport;
36
42
44 public override ReadOnlySpan<byte> SecurityControlBlock() => SecurityBlock.ReplyMessageWithDataSecurity;
45
51 internal static InputStatus ParseData(ReadOnlySpan<byte> data)
52 {
53 return new InputStatus(data.ToArray().Select(b => (InputStatusValue)b).ToArray());
54 }
55
57 public override byte[] BuildData() => InputStatuses.Select(x => (byte)x).ToArray();
58
60 public override string ToString()
61 {
62 byte inputNumber = 0;
63 var build = new StringBuilder();
64 foreach (InputStatusValue inputStatus in InputStatuses)
65 {
66 build.AppendLine($"Input Number {inputNumber++:00}: {inputStatus}");
67 }
68
69 return build.ToString();
70 }
71 }
72}
Contains standard Security Control Block data that can be used when building messages.
Base class representing a payload an OSDP message.
Definition PayloadData.cs:9
InputStatus(bool[] statuses)
Initializes a new instance of InputStatus class with boolean values for backward compatibility.
override ReadOnlySpan< byte > SecurityControlBlock()
InputStatusValue[] InputStatuses
Gets all the PD's input statuses as an array ordered by input number.
InputStatus(InputStatusValue[] statuses)
Initializes a new instance of InputStatus class.
ReplyType
Identifies the type of OSDP protocol reply (PD -> ACU) message.
Definition ReplyType.cs:7
InputStatusValue
Represents the possible states of an input as defined in Table 52 of the OSDP v2.2....