Compare commits
1 Commits
feat/Knowl
...
feat/detai
| Author | SHA1 | Date | |
|---|---|---|---|
| e61122449d |
@ -575,8 +575,12 @@ async function getVCDFileInfo(
|
|||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
|
console.log(`[getVCDFileInfo] 开始解析 VCD 文件: ${vcdFilePath}`);
|
||||||
|
console.log(`[getVCDFileInfo] containerId: ${containerId}`);
|
||||||
|
|
||||||
// 检查文件是否存在
|
// 检查文件是否存在
|
||||||
if (!fs.existsSync(vcdFilePath)) {
|
if (!fs.existsSync(vcdFilePath)) {
|
||||||
|
console.error(`[getVCDFileInfo] 文件不存在: ${vcdFilePath}`);
|
||||||
panel.webview.postMessage({
|
panel.webview.postMessage({
|
||||||
command: "vcdInfo",
|
command: "vcdInfo",
|
||||||
containerId: containerId,
|
containerId: containerId,
|
||||||
@ -615,8 +619,14 @@ async function getVCDFileInfo(
|
|||||||
timeRange = `${minTime} - ${maxTime}`;
|
timeRange = `${minTime} - ${maxTime}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析前几个信号的真实数据
|
// 解析信号的真实数据
|
||||||
const signals = parseVCDSignals(content, 3); // 只解析前3个信号
|
// 增加到20个信号,以便显示更多波形(平衡性能和完整性)
|
||||||
|
const signals = parseVCDSignals(content, 20);
|
||||||
|
|
||||||
|
console.log(`[getVCDFileInfo] 解析到 ${signals.length} 个有效信号`);
|
||||||
|
signals.forEach((sig, idx) => {
|
||||||
|
console.log(`[getVCDFileInfo] 信号${idx + 1}: ${sig.name}, 值变化数: ${sig.values.length}`);
|
||||||
|
});
|
||||||
|
|
||||||
// 发送信息回前端
|
// 发送信息回前端
|
||||||
panel.webview.postMessage({
|
panel.webview.postMessage({
|
||||||
@ -704,10 +714,13 @@ function parseVCDSignals(content: string, maxSignals: number = 3) {
|
|||||||
// 解析信号值变化
|
// 解析信号值变化
|
||||||
// 格式1: 单比特信号 "0!" 或 "1!"
|
// 格式1: 单比特信号 "0!" 或 "1!"
|
||||||
// 格式2: 多比特信号 "b1010 !"
|
// 格式2: 多比特信号 "b1010 !"
|
||||||
|
// 转义标识符中的特殊字符
|
||||||
|
const escapedId = signalDef.identifier.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
|
|
||||||
if (signalDef.width === 1) {
|
if (signalDef.width === 1) {
|
||||||
// 单比特信号
|
// 单比特信号
|
||||||
const singleBitMatch = trimmedLine.match(
|
const singleBitMatch = trimmedLine.match(
|
||||||
new RegExp(`^([01xz])${signalDef.identifier}$`)
|
new RegExp(`^([01xz])${escapedId}$`)
|
||||||
);
|
);
|
||||||
if (singleBitMatch) {
|
if (singleBitMatch) {
|
||||||
values.push({ time: currentTime, value: singleBitMatch[1] });
|
values.push({ time: currentTime, value: singleBitMatch[1] });
|
||||||
@ -715,7 +728,7 @@ function parseVCDSignals(content: string, maxSignals: number = 3) {
|
|||||||
} else {
|
} else {
|
||||||
// 多比特信号
|
// 多比特信号
|
||||||
const multiBitMatch = trimmedLine.match(
|
const multiBitMatch = trimmedLine.match(
|
||||||
new RegExp(`^b([01xz]+)\\s+${signalDef.identifier}$`)
|
new RegExp(`^b([01xz]+)\\s+${escapedId}$`)
|
||||||
);
|
);
|
||||||
if (multiBitMatch) {
|
if (multiBitMatch) {
|
||||||
values.push({ time: currentTime, value: multiBitMatch[1] });
|
values.push({ time: currentTime, value: multiBitMatch[1] });
|
||||||
@ -728,6 +741,8 @@ function parseVCDSignals(content: string, maxSignals: number = 3) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 只添加有值变化数据的信号
|
||||||
|
if (values.length > 0) {
|
||||||
signals.push({
|
signals.push({
|
||||||
name: signalDef.name,
|
name: signalDef.name,
|
||||||
identifier: signalDef.identifier,
|
identifier: signalDef.identifier,
|
||||||
@ -735,6 +750,7 @@ function parseVCDSignals(content: string, maxSignals: number = 3) {
|
|||||||
values: values,
|
values: values,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("解析 VCD 信号数据失败:", error);
|
console.error("解析 VCD 信号数据失败:", error);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,7 +91,14 @@ export async function handleUserMessage(
|
|||||||
// 尝试使用后端服务
|
// 尝试使用后端服务
|
||||||
if (useBackendService && extensionPath) {
|
if (useBackendService && extensionPath) {
|
||||||
try {
|
try {
|
||||||
await handleUserMessageWithBackend(panel, text, extensionPath, mode, undefined, serviceTier);
|
await handleUserMessageWithBackend(
|
||||||
|
panel,
|
||||||
|
text,
|
||||||
|
extensionPath,
|
||||||
|
mode,
|
||||||
|
undefined,
|
||||||
|
serviceTier
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("后端服务不可用:", error);
|
console.error("后端服务不可用:", error);
|
||||||
@ -137,10 +144,18 @@ async function handleUserMessageWithBackend(
|
|||||||
|
|
||||||
// 创建或复用会话
|
// 创建或复用会话
|
||||||
if (!currentSession || !currentSession.active) {
|
if (!currentSession || !currentSession.active) {
|
||||||
currentSession = dialogManager.createSession(extensionPath, taskIdToUse || undefined);
|
currentSession = dialogManager.createSession(
|
||||||
|
extensionPath,
|
||||||
|
taskIdToUse || undefined
|
||||||
|
);
|
||||||
// 保存 taskId 用于后续操作(如压缩)
|
// 保存 taskId 用于后续操作(如压缩)
|
||||||
lastTaskId = currentSession.getTaskId();
|
lastTaskId = currentSession.getTaskId();
|
||||||
console.log("[MessageHandler] 创建会话: taskId=", lastTaskId, "来源=", taskIdToUse ? "historyManager" : "新生成");
|
console.log(
|
||||||
|
"[MessageHandler] 创建会话: taskId=",
|
||||||
|
lastTaskId,
|
||||||
|
"来源=",
|
||||||
|
taskIdToUse ? "historyManager" : "新生成"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示状态栏
|
// 显示状态栏
|
||||||
|
|||||||
@ -218,8 +218,16 @@ export function getWaveformPreviewScript(): string {
|
|||||||
* 渲染波形预览信息
|
* 渲染波形预览信息
|
||||||
*/
|
*/
|
||||||
function renderWaveformInfo(containerId, vcdInfo) {
|
function renderWaveformInfo(containerId, vcdInfo) {
|
||||||
|
console.log('[renderWaveformInfo] 开始渲染波形, containerId:', containerId);
|
||||||
|
console.log('[renderWaveformInfo] vcdInfo:', vcdInfo);
|
||||||
|
|
||||||
const container = document.getElementById(containerId);
|
const container = document.getElementById(containerId);
|
||||||
if (!container) return;
|
if (!container) {
|
||||||
|
console.error('[renderWaveformInfo] 找不到容器:', containerId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('[renderWaveformInfo] 找到容器,信号数量:', vcdInfo.signals?.length || 0);
|
||||||
|
|
||||||
// 清空容器
|
// 清空容器
|
||||||
container.innerHTML = '';
|
container.innerHTML = '';
|
||||||
@ -229,6 +237,7 @@ export function getWaveformPreviewScript(): string {
|
|||||||
waveformSvg.innerHTML = drawRealWaveform(vcdInfo.signals || []);
|
waveformSvg.innerHTML = drawRealWaveform(vcdInfo.signals || []);
|
||||||
|
|
||||||
container.appendChild(waveformSvg);
|
container.appendChild(waveformSvg);
|
||||||
|
console.log('[renderWaveformInfo] 波形渲染完成');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user