feat: 逻辑分析仪深度可用户输入自定义数字
This commit is contained in:
@@ -76,28 +76,12 @@ const channelDivOptions = [
|
||||
{ value: 32, label: "32通道", description: "启用32个通道 (CH0-CH31)" },
|
||||
];
|
||||
|
||||
// 捕获深度选项
|
||||
const captureLengthOptions = [
|
||||
{ value: 256, label: "256" },
|
||||
{ value: 512, label: "512" },
|
||||
{ value: 1024, label: "1K" },
|
||||
{ value: 2048, label: "2K" },
|
||||
{ value: 4096, label: "4K" },
|
||||
{ value: 8192, label: "8K" },
|
||||
{ value: 16384, label: "16K" },
|
||||
{ value: 32768, label: "32K" },
|
||||
];
|
||||
// 捕获深度限制常量
|
||||
const CAPTURE_LENGTH_MIN = 1024; // 最小捕获深度 1024
|
||||
const CAPTURE_LENGTH_MAX = 0x10000000 - 0x01000000; // 最大捕获深度
|
||||
|
||||
// 预捕获深度选项
|
||||
const preCaptureLengthOptions = [
|
||||
{ value: 0, label: "0" },
|
||||
{ value: 16, label: "16" },
|
||||
{ value: 32, label: "32" },
|
||||
{ value: 64, label: "64" },
|
||||
{ value: 128, label: "128" },
|
||||
{ value: 256, label: "256" },
|
||||
{ value: 512, label: "512" },
|
||||
];
|
||||
// 预捕获深度限制常量
|
||||
const PRE_CAPTURE_LENGTH_MIN = 0; // 最小预捕获深度 0
|
||||
|
||||
// 默认颜色数组
|
||||
const defaultColors = [
|
||||
@@ -126,8 +110,8 @@ const [useProvideLogicAnalyzer, useLogicAnalyzerState] = createInjectionState(
|
||||
// 触发设置相关状态
|
||||
const currentGlobalMode = ref<GlobalCaptureMode>(GlobalCaptureMode.AND);
|
||||
const currentChannelDiv = ref<number>(8); // 默认启用8个通道
|
||||
const captureLength = ref<number>(1024); // 捕获深度,默认1024
|
||||
const preCaptureLength = ref<number>(0); // 预捕获深度,默认0
|
||||
const captureLength = ref<number>(CAPTURE_LENGTH_MIN); // 捕获深度,默认为最小值
|
||||
const preCaptureLength = ref<number>(PRE_CAPTURE_LENGTH_MIN); // 预捕获深度,默认0
|
||||
const isApplying = ref(false);
|
||||
const isCapturing = ref(false); // 添加捕获状态标识
|
||||
|
||||
@@ -181,6 +165,64 @@ const [useProvideLogicAnalyzer, useLogicAnalyzerState] = createInjectionState(
|
||||
}
|
||||
};
|
||||
|
||||
// 验证捕获深度
|
||||
const validateCaptureLength = (value: number): { valid: boolean; message?: string } => {
|
||||
if (!Number.isInteger(value)) {
|
||||
return { valid: false, message: "捕获深度必须是整数" };
|
||||
}
|
||||
if (value < CAPTURE_LENGTH_MIN) {
|
||||
return { valid: false, message: `捕获深度不能小于 ${CAPTURE_LENGTH_MIN}` };
|
||||
}
|
||||
if (value > CAPTURE_LENGTH_MAX) {
|
||||
return { valid: false, message: `捕获深度不能大于 ${CAPTURE_LENGTH_MAX.toLocaleString()}` };
|
||||
}
|
||||
return { valid: true };
|
||||
};
|
||||
|
||||
// 验证预捕获深度
|
||||
const validatePreCaptureLength = (value: number, currentCaptureLength: number): { valid: boolean; message?: string } => {
|
||||
if (!Number.isInteger(value)) {
|
||||
return { valid: false, message: "预捕获深度必须是整数" };
|
||||
}
|
||||
if (value < PRE_CAPTURE_LENGTH_MIN) {
|
||||
return { valid: false, message: `预捕获深度不能小于 ${PRE_CAPTURE_LENGTH_MIN}` };
|
||||
}
|
||||
if (value >= currentCaptureLength) {
|
||||
return { valid: false, message: `预捕获深度不能大于等于捕获深度 (${currentCaptureLength})` };
|
||||
}
|
||||
return { valid: true };
|
||||
};
|
||||
|
||||
// 设置捕获深度
|
||||
const setCaptureLength = (value: number) => {
|
||||
const validation = validateCaptureLength(value);
|
||||
if (!validation.valid) {
|
||||
alert?.error(validation.message!, 3000);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查预捕获深度是否仍然有效
|
||||
if (preCaptureLength.value >= value) {
|
||||
preCaptureLength.value = Math.max(0, value - 1);
|
||||
alert?.warn(`预捕获深度已自动调整为 ${preCaptureLength.value}`, 3000);
|
||||
}
|
||||
|
||||
captureLength.value = value;
|
||||
return true;
|
||||
};
|
||||
|
||||
// 设置预捕获深度
|
||||
const setPreCaptureLength = (value: number) => {
|
||||
const validation = validatePreCaptureLength(value, captureLength.value);
|
||||
if (!validation.valid) {
|
||||
alert?.error(validation.message!, 3000);
|
||||
return false;
|
||||
}
|
||||
|
||||
preCaptureLength.value = value;
|
||||
return true;
|
||||
};
|
||||
|
||||
// 设置通道组
|
||||
const setChannelDiv = (channelCount: number) => {
|
||||
// 验证通道数量是否有效
|
||||
@@ -717,8 +759,15 @@ const [useProvideLogicAnalyzer, useLogicAnalyzerState] = createInjectionState(
|
||||
operators,
|
||||
signalValues,
|
||||
channelDivOptions, // 导出通道组选项
|
||||
captureLengthOptions, // 导出捕获深度选项
|
||||
preCaptureLengthOptions, // 导出预捕获深度选项
|
||||
|
||||
// 捕获深度常量和验证
|
||||
CAPTURE_LENGTH_MIN,
|
||||
CAPTURE_LENGTH_MAX,
|
||||
PRE_CAPTURE_LENGTH_MIN,
|
||||
validateCaptureLength,
|
||||
validatePreCaptureLength,
|
||||
setCaptureLength,
|
||||
setPreCaptureLength,
|
||||
|
||||
// 触发设置方法
|
||||
setChannelDiv, // 导出设置通道组方法
|
||||
|
||||
Reference in New Issue
Block a user