Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,41 @@ _Avoid_:已开始录制、启动准备中、取消请求即完成
**停止许可(Stop Permission)**:本次执行已经确认可以接受操作员停止请求的事实;预约等待与实际运行均可具有停止许可。它不表示执行已经结束,也不允许在停止收尾期间再次启动。
_Avoid_:实际采集开始、资源已经释放

## CAN 业务术语

**CAN 总开关(CAN Enable Switch)**:用户允许设备使用 CAN 的总控制,开启后业务才能使用该设备的 CAN 端口;开启本身不表示端口正在接收。
_Avoid_:开始测量、端口接收状态

**CAN 原始报文录制(Raw CAN Recording)**:对一个设备端口在手动开始至结束期间收到的报文形成的独立记录,可作为全局诊断历史查看与下载,不随工程归属。
_Avoid_:Monitor Recorder、解码信号历史、表格筛选结果

**CAN 端口(CAN Port)**:设备提供的一路 CAN 总线接口,具有自己的接收配置和接收状态。同一设备的不同端口不表示主备关系。
_Avoid_:解码信号通道、固定收发方向

**CAN 接收使用关系(CAN Reception Usage)**:某个业务或手动接收操作对指定端口数据的持续使用。多个使用关系可以共用一次接收,结束其中一个不表示其他使用也已结束。
_Avoid_:配置弹窗是否打开、独立硬件接收、图表是否可见

**CAN 配置草稿(CAN Configuration Draft)**:用户正在编辑、尚未成功应用的一份端口配置,与已应用配置分别保留。
_Avoid_:已生效硬件参数、已应用配置

**已应用 CAN 配置(Applied CAN Configuration)**:用户通过 Apply 成功接受并保存、供端口接收使用的配置。它本身不表示已经开始接收,也不等同于硬件实际回读值。
_Avoid_:未应用草稿、硬件回读、正在接收

**CAN 解码录制(Recorded CAN Signals)**:Recorder 在一次工程测试中保存的 CAN 信号值、时间和有效性记录,按录制当时的通道与解码定义解释。历史回放使用已保存的解码结果,不依赖当前设备或后来修改的 DBC。
_Avoid_:全局原始报文录制、音频 WAV、按新规则重新解码

**CAN 原始帧(Raw CAN Frame)**:从总线接收的一条报文,包含标识、帧格式、载荷及来源时间信息。
_Avoid_:解码值、音频采样块

**CAN 信号通道(CAN Signal Channel)**:由指定设备端口上的报文和解码规则定义的一路物理量,具有名称、单位和有效性规则。
_Avoid_:CAN 硬件端口、等间隔音频输入

**端口接收过滤(CAN Receive Filter)**:决定哪些报文进入该端口接收结果的规则,对使用该接收结果的消费者共同生效。
_Avoid_:Raw Frames 页面筛选

**原始帧显示筛选(Raw Frame Display Filter)**:从已接收报文中选择页面展示内容的条件,不改变端口接收范围。
_Avoid_:硬件接收过滤器

## 波形采集时间

**设备采集时间戳**:连续采集接口随波形数据返回的采样时间标记;其时钟基准由采集来源决定,不统一认定为 UTC。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

public enum ChannelSourceEnum implements BaseEnum {
PHYSICAL(0),
MATH(1);
MATH(1),
CAN(2);

private final Integer value;

Expand All @@ -26,4 +27,12 @@ public String getDescription() {
public static boolean isMath(Integer value) {
return ObjectUtil.equal(MATH.value, value);
}

public static boolean isCan(Integer value) {
return ObjectUtil.equal(CAN.value, value);
}

public static boolean isPhysical(Integer value) {
return value == null || ObjectUtil.equal(PHYSICAL.value, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public enum FileTypeEnum {
* Word Open XML 模板格式
*/
DOCX(13, "DOCX", ".docx"),
CAN_EVENTS(14, "CAN_EVENTS", ".can-events.jsonl"),
;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,9 @@ public enum ErrorCode {
1300004,
"Dashboard has not been first-created, projectId={}, providerId={}",
"error.dashboard.execution.not.first.created"),
CAN_RECORDER_UNAVAILABLE(1301001,
"CAN recording and history are not available yet. Use live Monitor or remove CAN inputs.",
"error.can.recorder.unavailable"),
SOUND_POWER_ROOM_DIMENSIONS_INVALID(12090155,
"Enter valid room length, width and height before sound power measurement. Each dimension and the calculated room surface area must be finite and greater than zero.",
"error.sound.power.room.dimensions.invalid"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.opentest.dashboard.api.channel.MathSampleSemantics;
import cn.hutool.core.convert.Convert;
import com.opentest.common.model.BaseModel;
import com.opentest.common.enums.ChannelSourceEnum;
import com.opentest.common.model.entity.Device;
import com.opentest.common.model.validation.ValidationOptNumQuery;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
Expand Down Expand Up @@ -82,6 +83,8 @@ public class BoxChannelDto extends BaseModel implements Serializable {
*/
private Integer channelSource;

private String canDefinitionJson;

/**
* 自定义名称
*/
Expand Down Expand Up @@ -306,6 +309,7 @@ public static class BoxChannelItem implements Serializable {
private Collection<BoxChannelItem> boxChannelItems;

public Double getGain() {
if (ChannelSourceEnum.isCan(channelSource)) return null;
if ("OPENDAQ".equals(protocol)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.opentest.common.model.dto;

import lombok.Data;

import java.io.Serializable;

@Data
public class CanChannelSaveRequestDto implements Serializable {
private Long id;
private Long projectId;
private String vchId;
private Long deviceId;
private String customName;
private String channelColor;
private String canDefinitionJson;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.opentest.common.model.dto;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/** Versioned request-owned CAN event artifact; absent in sampled-only legacy histories. */
@Data
public class CanRecordingSectionDto implements Serializable {
private int version = 1;
private String requestId;
/** Original immutable event-header owner after project import; absent in original V1 recordings. */
private String sourceRequestId;
private Map<String, Map<String, Object>> channels;
private List<ClockAnchor> clockAnchors;
private String businessId;
private String fileId;
private String relativePath;
private long byteLength;
private String sha256;
private long batchCount;
private String status;
private String terminationReason;
private String failure;
private List<Map<String, Object>> nativeFinishSnapshots;

@Data
@NoArgsConstructor
@AllArgsConstructor
public static class ClockAnchor implements Serializable {
private double observationSeconds;
private double recordingSeconds;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public class ChannelDto extends BaseModel implements Serializable {
*/
private Integer channelSource;

private String canDefinitionJson;

/**
* 通道类型描述
*/
Expand Down Expand Up @@ -490,6 +492,7 @@ public String getFileName() {

@JsonProperty(access = JsonProperty.Access.READ_ONLY)
public Double getGain() {
if (ChannelSourceEnum.isCan(channelSource)) return null;
// if ("OPENDAQ".equals(protocol)) {
// return null;
// }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ public String toJson() {
/** Absent for legacy recordings reconstructed from physical dependencies. */
private RecordedWaveformPlanDto recordedWaveformPlan;

/** Frozen irregular CAN inputs and exact request file binding; null for legacy histories. */
@SavedMeasurementInputSection
private CanRecordingSectionDto canRecording;

/** FFT 已完成带宽准备的工程通道采样率;null 表示尚未准备,空表表示无需调整。 */
private Map<Long, Integer> fftInputBandwidthSamplingRates;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
*/
@Data
public class RenderDataDto implements Serializable {
public record CanUnitConversion(String sourceUnit, String targetUnit, double scale, double offset) implements Serializable { }

@JsonInclude(JsonInclude.Include.ALWAYS)
private CanUnitConversion canUnitConversion;

private ResultUnitIdentity resultUnitIdentity;
private MathSampleSemantics mathSampleSemantics;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public class BoxChannel extends BaseModel {
*/
private Integer channelSource;

private String canDefinitionJson;

/**
* 自定义名称
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ public class CanJNIBridge {
/** Reads this subscription only; samples include definitionRevision and selectionRevision. */
public native String readCanSignalSubscriptionV1(String receiveId, String subscriptionId, int maxSamples, int timeoutMs);

/**
* Seals this subscription and drains up to 1..256 queued events per call, within the JSON byte budget.
* Repeat until drained=true; complete reports frozen integrity independently. Retains ownership until unsubscribe.
* Requires the optional matching JNI export. Callers must serialize polling, write handoff and finish.
*/
public native String finishAndDrainCanSignalSubscriptionV1(String receiveId, String subscriptionId, int maxSamples);

/**
* Clears one business subscription. Others continue; if last and rawFrames=false,
* stops/releases port reception while retaining device CAN enable and saved configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.Map;
import java.util.Objects;
import com.opentest.dashboard.api.channel.ChannelMetadata;
import com.opentest.dashboard.api.channel.CanSignalChannel;
import com.opentest.dashboard.api.frame.ResultFrame;

/** Host-bound metadata for exact frozen measurement file targets. This does not grant input authority. */
Expand All @@ -20,20 +21,52 @@ public record Key(String resultCode, String hash, String memberId, String unitX,
}
}

public record Target(long dashboardResultId, Key key, ChannelMetadata metadata, ResultFileUnitIdentity fileUnitIdentity, ResultUnitIdentity resultUnitIdentityY) {
public Target(long dashboardResultId, Key key, ChannelMetadata metadata, ResultFileUnitIdentity fileUnitIdentity) {
this(dashboardResultId, key, metadata, fileUnitIdentity, null);
}
public sealed interface Source permits SampledSource, CanSource { }
public record SampledSource(ChannelMetadata metadata) implements Source {
public SampledSource { Objects.requireNonNull(metadata); }
}
public record CanSource(CanSignalChannel channel) implements Source {
public CanSource { Objects.requireNonNull(channel); }
}

public record Target(long dashboardResultId, Key key, ChannelMetadata metadata,
ResultFileUnitIdentity fileUnitIdentity, ResultUnitIdentity resultUnitIdentityY, Source source) {
public Target(long dashboardResultId, Key key, ChannelMetadata metadata) {
this(dashboardResultId, key, metadata, ResultFileUnitIdentity.Y_ONLY);
}
public Target(long dashboardResultId, Key key, ChannelMetadata metadata, ResultFileUnitIdentity identity) {
this(dashboardResultId, key, metadata, identity, null);
}
public Target(long dashboardResultId, Key key, ChannelMetadata metadata, ResultFileUnitIdentity identity,
ResultUnitIdentity resultUnitIdentityY) {
this(dashboardResultId, key, metadata, identity, resultUnitIdentityY, new SampledSource(metadata));
}
public static Target can(long dashboardResultId, Key key, CanSignalChannel channel, ResultFileUnitIdentity identity) {
return can(dashboardResultId, key, channel, identity, null);
}
public static Target can(long dashboardResultId, Key key, CanSignalChannel channel, ResultFileUnitIdentity identity,
ResultUnitIdentity resultUnitIdentityY) {
return new Target(dashboardResultId, key, null, identity, resultUnitIdentityY, new CanSource(channel));
}
public ChannelMetadata metadata() {
Comment thread
yangdekun2026 marked this conversation as resolved.
Resolved
if (source instanceof SampledSource sampled) return sampled.metadata();
throw new IllegalArgumentException("CAN file target has no sampled channel metadata");
}
public Target {
if (dashboardResultId <= 0) throw new IllegalArgumentException("A genuine measurement result is required");
Objects.requireNonNull(key);
Objects.requireNonNull(fileUnitIdentity);
Objects.requireNonNull(metadata);
if (!key.memberId().equals(metadata.vchId()))
Objects.requireNonNull(source);
if (source instanceof SampledSource sampled && !sampled.metadata().equals(metadata)
|| source instanceof CanSource && metadata != null)
throw new IllegalArgumentException("Measurement file source disagrees with sampled metadata");
String member = source instanceof SampledSource sampled ? sampled.metadata().vchId()
: ((CanSource) source).channel().vchId();
if (!key.memberId().equals(member))
throw new IllegalArgumentException("Measurement file metadata belongs to another member");
if (source instanceof CanSource can && (!can.channel().units().outputUnits().contains(key.unitY())
|| key.unitX() != null && !"s".equals(key.unitX())))
throw new IllegalArgumentException("CAN file target requires its frozen units and seconds axis");
}
}

Expand All @@ -60,7 +93,8 @@ public Target require(ResultFrame frame) {
var key = new Key(frame.resultCode(), frame.hash(), frame.vchId(), frame.unitX(), frame.unitY());
var target = targets.get(new TargetKey(frame.dashboardResultId(), key));
if (target == null) throw new IllegalArgumentException("Undeclared measurement file target: " + key);
if (target.metadata().mathSampleSemantics() == MathSampleSemantics.RAW_FS_CUSTOM
if (target.source() instanceof SampledSource sampled
&& sampled.metadata().mathSampleSemantics() == MathSampleSemantics.RAW_FS_CUSTOM
&& (target.resultUnitIdentityY() == null || frame.outputMetadata().resultUnitIdentityY() != target.resultUnitIdentityY()))
throw new IllegalArgumentException("Custom Math output requires its explicit frozen result unit identity");
return target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@
public final class MeasurementResultFileProjection {
private MeasurementResultFileProjection() { }

public static XYData projectTarget(String logicalFileName, ResultFrame frame,
MeasurementResultFileMetadata.Target target, Layout layout, SensitivityFields sensitivityFields) {
if (target.source() instanceof MeasurementResultFileMetadata.SampledSource sampled)
return project(logicalFileName, frame, sampled.metadata(), layout, sensitivityFields);
double[] x = frame.outputMetadata().outputXCoordinates();
if (x == null) x = frame.x();
if (layout != Layout.FRAMED || x == null || x.length != frame.y().length
|| frame.xStep() != null || frame.outputMetadata().stepMs() != null
|| frame.outputMetadata().persistedHeaderStepMs() != null
|| frame.outputMetadata().persistedIndexSampleCount() != null
|| frame.outputMetadata().persistedIndexEndTimeMs() != null
|| frame.outputMetadata().fullScaleBasis() != null)
throw new IllegalArgumentException("CAN numeric results require irregular explicit X and no sampled metadata");
double previous = -1;
for (double value : x) {
if (!Double.isFinite(value) || value < 0 || value < previous)
throw new IllegalArgumentException("CAN numeric X must be ordered finite seconds");
previous = value;
}
return project(logicalFileName, frame, null, layout, sensitivityFields);
}

public static XYData project(String logicalFileName, ResultFrame frame, ChannelMetadata channel,
Layout layout, SensitivityFields sensitivityFields) {
XYData.Metadata metadata = new XYData.Metadata();
Expand Down
Loading
Loading