OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
LocalStatus.cs
3using System;
4using System.Text;
5
7{
11 public class LocalStatus : PayloadData
12 {
18 public LocalStatus(bool tamper, bool powerFailure)
19 {
20 Tamper = tamper;
21 PowerFailure = powerFailure;
22 }
23
25 public override byte Code => (byte)ReplyType.LocalStatusReport;
26
31 public bool Tamper { get; }
32
37 public bool PowerFailure { get; }
38
40 public override ReadOnlySpan<byte> SecurityControlBlock() => SecurityBlock.ReplyMessageWithDataSecurity;
41
46 internal static LocalStatus ParseData(ReadOnlySpan<byte> data)
47 {
48 var dataArray = data.ToArray();
49 if (dataArray.Length < 2)
50 {
51 throw new Exception("Invalid size for the data");
52 }
53
54 return new LocalStatus(
55 Convert.ToBoolean(dataArray[0]), Convert.ToBoolean(dataArray[1]));
56 }
57
59 public override byte[] BuildData() => [
60 Tamper ? (byte)0x01 : (byte)0x00,
61 PowerFailure ? (byte)0x01 : (byte)0x00];
62
64 public override string ToString()
65 {
66 var build = new StringBuilder();
67 build.AppendLine($" Tamper: {Tamper}");
68 build.AppendLine($"Power Failure: {PowerFailure}");
69
70 return build.ToString();
71 }
72 }
73}
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
override ReadOnlySpan< byte > SecurityControlBlock()
LocalStatus(bool tamper, bool powerFailure)
Initializes a new instance of LocalStatus class.
bool PowerFailure
Gets a value indicating whether this PD is experiencing a power failure.
bool Tamper
Gets a value indicating whether this PD is tamper.
override byte[]? PowerFailure(byte) 0x01 override string ToString()
ReplyType
Identifies the type of OSDP protocol reply (PD -> ACU) message.
Definition ReplyType.cs:7