69 lines
2.1 KiB
C#
69 lines
2.1 KiB
C#
namespace SSPCTester.Devices.Interfaces;
|
||
|
||
/// <summary>
|
||
/// 一段高速采集得到的电压波形。
|
||
/// </summary>
|
||
public sealed class CurveData
|
||
{
|
||
/// <summary>采样率(Hz)。</summary>
|
||
public int SampleRateHz { get; init; }
|
||
|
||
/// <summary>触发时刻(相对于采样起点,单位:秒)。</summary>
|
||
public double TriggerTimeSec { get; init; }
|
||
public int TriggerSampleIndex { get; init; }
|
||
|
||
/// <summary>电压样点数组(V)。索引 i 对应时间 i / SampleRateHz。</summary>
|
||
public required double[] Voltage { get; init; }
|
||
|
||
/// <summary>电流样点数组(A),可选。</summary>
|
||
public double[]? Current { get; init; }
|
||
public IReadOnlyList<CurveChannelData> EngineeringChannels { get; init; } = Array.Empty<CurveChannelData>();
|
||
|
||
/// <summary>样点数。</summary>
|
||
public int Length => Voltage.Length;
|
||
|
||
/// <summary>总时长(s)。</summary>
|
||
public double DurationSec => SampleRateHz > 0 ? (double)Voltage.Length / SampleRateHz : 0;
|
||
|
||
/// <summary>给定索引对应的时间(s)。</summary>
|
||
public double TimeAt(int index) => SampleRateHz > 0 ? (double)index / SampleRateHz : 0;
|
||
}
|
||
|
||
public sealed record CurveChannelData(
|
||
int PhysicalChannel,
|
||
DaqChannelRole Role,
|
||
string Name,
|
||
string Unit,
|
||
double Scale,
|
||
double Offset,
|
||
double[] Samples);
|
||
|
||
public enum DaqChannelRole
|
||
{
|
||
Unconfigured,
|
||
OutputVoltage,
|
||
OutputCurrent,
|
||
InputVoltage,
|
||
InputCurrent,
|
||
Auxiliary
|
||
}
|
||
|
||
public sealed record DaqDeviceDescriptor(
|
||
int LogicalId,
|
||
int? PhysicalId,
|
||
string Description,
|
||
bool IsSimulated)
|
||
{
|
||
public override string ToString() =>
|
||
PhysicalId.HasValue
|
||
? $"{Description}(逻辑 {LogicalId} / 物理 {PhysicalId})"
|
||
: $"{Description}(逻辑 {LogicalId})";
|
||
}
|
||
|
||
public sealed record DaqActionCaptureRequest(double PreTriggerMs, double PostTriggerMs, bool IsRising);
|
||
|
||
/// <summary>
|
||
/// 单个采样点(流式推送时使用)。
|
||
/// </summary>
|
||
public readonly record struct CurveSample(double TimeSec, double Voltage, double Current);
|