SSPC-Tester/SSPCTester.Devices/Interfaces/CurveData.cs
2026-06-30 12:10:29 +08:00

69 lines
2.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);