-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDiscreteUnitOfOutput.cs
More file actions
64 lines (59 loc) · 2.55 KB
/
DiscreteUnitOfOutput.cs
File metadata and controls
64 lines (59 loc) · 2.55 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
// =================================================================================================================================
// Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
// =================================================================================================================================
using RapidField.SolidInstruments.Core.ArgumentValidation;
using System;
namespace RapidField.SolidInstruments.SignalProcessing
{
/// <summary>
/// Represents a discrete unit of output from an <see cref="IChannel" />.
/// </summary>
/// <remarks>
/// <see cref="DiscreteUnitOfOutput{T}" /> is the default implementation of <see cref="IDiscreteUnitOfOutput{T}" />.
/// </remarks>
/// <typeparam name="T">
/// The type of the associated channel's output value.
/// </typeparam>
public sealed class DiscreteUnitOfOutput<T> : IDiscreteUnitOfOutput<T>
{
/// <summary>
/// Initializes a new instance of the <see cref="DiscreteUnitOfOutput{T}" /> class.
/// </summary>
/// <param name="value">
/// The output value.
/// </param>
/// <param name="channelReadIndex">
/// The zero-based index for the output value within the associated channel's output stream.
/// </param>
/// <exception cref="ArgumentOutOfRangeException">
/// <paramref name="channelReadIndex" /> is less than zero.
/// </exception>
public DiscreteUnitOfOutput(T value, Int32 channelReadIndex)
{
ChannelReadIndex = channelReadIndex.RejectIf().IsLessThan(0, nameof(channelReadIndex));
Value = value;
}
/// <summary>
/// Converts the value of the current <see cref="DiscreteUnitOfOutput{T}" /> to its equivalent string representation.
/// </summary>
/// <returns>
/// A string representation of the current <see cref="DiscreteUnitOfOutput{T}" />.
/// </returns>
public override String ToString() => $"{{ \"{nameof(ChannelReadIndex)}\": {ChannelReadIndex}, \"{nameof(Value)}\": \"{Value}\" }}";
/// <summary>
/// Gets the zero-based index for the current <see cref="DiscreteUnitOfOutput{T}" /> within the associated channel's output
/// stream.
/// </summary>
public Int32 ChannelReadIndex
{
get;
}
/// <summary>
/// Gets the output value.
/// </summary>
public T Value
{
get;
}
}
}