feat:暂存修改+还未测试

This commit is contained in:
Roe-xin
2026-01-10 10:19:49 +08:00
parent 4687c3faa6
commit e61122449d
3 changed files with 57 additions and 17 deletions

View File

@ -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,12 +741,15 @@ function parseVCDSignals(content: string, maxSignals: number = 3) {
} }
} }
signals.push({ // 只添加有值变化数据的信号
name: signalDef.name, if (values.length > 0) {
identifier: signalDef.identifier, signals.push({
width: signalDef.width, name: signalDef.name,
values: values, identifier: signalDef.identifier,
}); width: signalDef.width,
values: values,
});
}
} }
} catch (error) { } catch (error) {
console.error("解析 VCD 信号数据失败:", error); console.error("解析 VCD 信号数据失败:", error);

View File

@ -59,7 +59,7 @@ export async function handleUserMessage(
text: string, text: string,
extensionPath?: string, extensionPath?: string,
mode?: RunMode, mode?: RunMode,
serviceTier?: ServiceTier // 新增:服务等级参数 serviceTier?: ServiceTier // 新增:服务等级参数
) { ) {
console.log("收到用户消息:", text); console.log("收到用户消息:", text);
@ -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);
@ -127,7 +134,7 @@ async function handleUserMessageWithBackend(
extensionPath: string, extensionPath: string,
mode?: RunMode, mode?: RunMode,
reuseTaskId?: string, // 可选,复用现有 taskId用于 Plan 模式确认后继续执行) reuseTaskId?: string, // 可选,复用现有 taskId用于 Plan 模式确认后继续执行)
serviceTier?: ServiceTier // 新增:服务等级参数 serviceTier?: ServiceTier // 新增:服务等级参数
): Promise<void> { ): Promise<void> {
const historyManager = ChatHistoryManager.getInstance(); const historyManager = ChatHistoryManager.getInstance();
@ -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" : "新生成"
);
} }
// 显示状态栏 // 显示状态栏
@ -290,7 +305,7 @@ async function handleUserMessageWithBackend(
}, },
}, },
mode, mode,
serviceTier // 传递服务等级 serviceTier // 传递服务等级
); );
}); });
} }

View File

@ -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] 波形渲染完成');
} }
/** /**