-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIChannel.cs
More file actions
210 lines (195 loc) · 8.94 KB
/
IChannel.cs
File metadata and controls
210 lines (195 loc) · 8.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
// =================================================================================================================================
// Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
// =================================================================================================================================
using RapidField.SolidInstruments.Core;
using System;
using System.Threading.Tasks;
namespace RapidField.SolidInstruments.SignalProcessing
{
/// <summary>
/// Represents a streaming data signal.
/// </summary>
/// <typeparam name="T">
/// The type of the channel's output value.
/// </typeparam>
public interface IChannel<T> : IChannel
{
/// <summary>
/// Gets the unit of output from the channel's output stream at the specified index.
/// </summary>
/// <param name="index">
/// A zero-based index within the output stream at which to read.
/// </param>
/// <returns>
/// The discrete unit of output from the channel's output stream at the specified index.
/// </returns>
/// <exception cref="IndexOutOfRangeException">
/// <see cref="InvalidReadBehavior" /> is equal to <see cref="InvalidReadBehavior.RaiseException" /> and the specified index
/// is out of range.
/// </exception>
/// <exception cref="ChannelReadException">
/// An exception was raised while performing the read operation, or the channel was unavailable.
/// </exception>
public T this[Int32 index]
{
get;
}
/// <summary>
/// Asynchronously reads a discrete unit of output from the channel's output stream at the specified index.
/// </summary>
/// <param name="index">
/// A zero-based index within the output stream at which to read.
/// </param>
/// <returns>
/// A task representing the asynchronous operation and containing a discrete unit of output from the channel's output stream
/// at the specified index.
/// </returns>
/// <exception cref="ArgumentOutOfRangeException">
/// <see cref="InvalidReadBehavior" /> is equal to <see cref="InvalidReadBehavior.RaiseException" /> and
/// <paramref name="index" /> is less than zero -or- <paramref name="index" /> exceeds the end boundary of the channel's
/// output stream.
/// </exception>
/// <exception cref="ChannelReadException">
/// An exception was raised while performing the read operation, or the channel was unavailable.
/// </exception>
public Task<IDiscreteUnitOfOutput<T>> ReadAsync(Int32 index);
/// <summary>
/// Asynchronously reads a sample from the channel's output stream at the specified index.
/// </summary>
/// <param name="index">
/// A zero-based index within the output stream at which to read.
/// </param>
/// <param name="lookBehindLength">
/// The number of discrete units of output preceding the specified index to include with the sample. The default value is
/// zero.
/// </param>
/// <returns>
/// A task representing the asynchronous operation and containing a sample from the channel's output stream at the specified
/// index.
/// </returns>
/// <exception cref="ArgumentOutOfRangeException">
/// <see cref="InvalidReadBehavior" /> is equal to <see cref="InvalidReadBehavior.RaiseException" /> and
/// <paramref name="index" /> is less than zero -or- <paramref name="lookBehindLength" /> is less than zero -or- the
/// resulting sample range precedes the start boundary of the channel's output stream -or- the resulting sample range
/// exceeds the end boundary of the channel's output stream.
/// </exception>
/// <exception cref="ChannelReadException">
/// An exception was raised while performing the read operation, or the channel was unavailable.
/// </exception>
public Task<ISignalSample<T>> ReadAsync(Int32 index, Int32 lookBehindLength);
/// <summary>
/// Asynchronously reads a sample from the channel's output stream at the specified index.
/// </summary>
/// <param name="index">
/// A zero-based index within the output stream at which to read.
/// </param>
/// <param name="lookBehindLength">
/// The number of discrete units of output preceding the specified index to include with the sample. The default value is
/// zero.
/// </param>
/// <param name="lookAheadLength">
/// The number of discrete units of output following the specified index to include with the sample. The default value is
/// zero.
/// </param>
/// <returns>
/// A task representing the asynchronous operation and containing a sample from the channel's output stream at the specified
/// index.
/// </returns>
/// <exception cref="ArgumentOutOfRangeException">
/// <see cref="InvalidReadBehavior" /> is equal to <see cref="InvalidReadBehavior.RaiseException" /> and
/// <paramref name="index" /> is less than zero -or- <paramref name="lookBehindLength" /> is less than zero -or-
/// <paramref name="lookAheadLength" /> is less than zero -or- the resulting sample range precedes the start boundary of the
/// channel's output stream -or- the resulting sample range exceeds the end boundary of the channel's output stream.
/// </exception>
/// <exception cref="ChannelReadException">
/// An exception was raised while performing the read operation, or the channel was unavailable.
/// </exception>
public Task<ISignalSample<T>> ReadAsync(Int32 index, Int32 lookBehindLength, Int32 lookAheadLength);
/// <summary>
/// Returns a discrete unit that represents a silent or empty signal.
/// </summary>
/// <returns>
/// A discrete unit that represents a silent or empty signal.
/// </returns>
public T ReadSilence();
/// <summary>
/// Returns a discrete unit that represents a silent or empty signal.
/// </summary>
/// <param name="index">
/// A zero-based index to include with the result.
/// </param>
/// <returns>
/// A discrete unit that represents a silent or empty signal.
/// </returns>
/// <exception cref="ArgumentOutOfRangeException">
/// <see cref="InvalidReadBehavior" /> is equal to <see cref="InvalidReadBehavior.RaiseException" /> and
/// <paramref name="index" /> is less than zero.
/// </exception>
public IDiscreteUnitOfOutput<T> ReadSilence(Int32 index);
/// <summary>
/// Gets the behavior of the channel when an out-of-range read request is made.
/// </summary>
public InvalidReadBehavior InvalidReadBehavior
{
get;
}
}
/// <summary>
/// Represents a streaming data signal.
/// </summary>
public interface IChannel : IInstrument
{
/// <summary>
/// Changes the channel's status to <see cref="ChannelStatus.Live" /> if it is currently silent, otherwise changes the
/// status to <see cref="ChannelStatus.Silent" /> if it is currently live, otherwise raises an
/// <see cref="InvalidOperationException" />.
/// </summary>
/// <exception cref="InvalidOperationException">
/// The channel's status is equal to <see cref="ChannelStatus.Unavailable" />.
/// </exception>
public void Toggle();
/// <summary>
/// Gets a unique identifier for the current <see cref="IChannel" />.
/// </summary>
public Guid Identifier
{
get;
}
/// <summary>
/// Gets the name of the current <see cref="IChannel" />.
/// </summary>
public String Name
{
get;
}
/// <summary>
/// Gets the number of discrete units in the output stream for the current <see cref="IChannel" />, or -1 if the length is
/// not fixed.
/// </summary>
public Int32 OutputLength
{
get;
}
/// <summary>
/// Gets a value indicating whether or not the output stream for the current <see cref="IChannel" /> has a fixed length.
/// </summary>
public Boolean OutputLengthIsFixed
{
get;
}
/// <summary>
/// Gets the type of a discrete unit of output value for the current <see cref="IChannel" />.
/// </summary>
public Type OutputType
{
get;
}
/// <summary>
/// Gets the status of the current <see cref="IChannel" />.
/// </summary>
public ChannelStatus Status
{
get;
}
}
}