OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
OsdpConnection.cs
1using System;
2using System.Threading;
3using System.Threading.Tasks;
4
6{
10 public abstract class OsdpConnection : IOsdpConnection
11 {
12 private bool _disposedValue;
13
18 protected OsdpConnection(int baudRate)
19 {
20 BaudRate = baudRate;
21 }
22
29 public int BaudRate { get; protected set; }
30
32 public virtual bool IsOpen { get; protected set; }
33
35 public TimeSpan ReplyTimeout { get; set; } = TimeSpan.FromMilliseconds(200);
36
38 public abstract Task Close();
39
41 public abstract Task Open();
42
44 public abstract Task<int> ReadAsync(byte[] buffer, CancellationToken token);
45
47 public abstract Task WriteAsync(byte[] buffer);
48
50 public void Dispose()
51 {
52 Dispose(disposing: true);
53 GC.SuppressFinalize(this);
54 }
55
63 protected virtual void Dispose(bool disposing)
64 {
65 if (!_disposedValue)
66 {
67 if (disposing)
68 {
69 Close();
70 }
71
72 _disposedValue = true;
73 }
74 }
75 }
76}
Task Open()
Open the connection for communications.
Task< int > ReadAsync(byte[] buffer, CancellationToken token)
Read from connection.Number of actual bytes read
int BaudRate
Speed of the connection.
TimeSpan ReplyTimeout
Timeout value waiting for a reply.
Task WriteAsync(byte[] buffer)
Write to connection.
OsdpConnection(int baudRate)
Creates an instance of OsdpConnection.
virtual bool IsOpen
Is the connection open and ready to communicate.
virtual void Dispose(bool disposing)
Disposes the OsdpConnection instance.
Task Close()
Close the connection for communications.
Defines a connection for communicating via OSDP protocol.