Compare commits
1 Commits
feat/back-
...
feat/detai
| Author | SHA1 | Date | |
|---|---|---|---|
| e61122449d |
@ -575,8 +575,12 @@ async function getVCDFileInfo(
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
console.log(`[getVCDFileInfo] 开始解析 VCD 文件: ${vcdFilePath}`);
|
||||
console.log(`[getVCDFileInfo] containerId: ${containerId}`);
|
||||
|
||||
// 检查文件是否存在
|
||||
if (!fs.existsSync(vcdFilePath)) {
|
||||
console.error(`[getVCDFileInfo] 文件不存在: ${vcdFilePath}`);
|
||||
panel.webview.postMessage({
|
||||
command: "vcdInfo",
|
||||
containerId: containerId,
|
||||
@ -615,8 +619,14 @@ async function getVCDFileInfo(
|
||||
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({
|
||||
@ -704,10 +714,13 @@ function parseVCDSignals(content: string, maxSignals: number = 3) {
|
||||
// 解析信号值变化
|
||||
// 格式1: 单比特信号 "0!" 或 "1!"
|
||||
// 格式2: 多比特信号 "b1010 !"
|
||||
// 转义标识符中的特殊字符
|
||||
const escapedId = signalDef.identifier.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
|
||||
if (signalDef.width === 1) {
|
||||
// 单比特信号
|
||||
const singleBitMatch = trimmedLine.match(
|
||||
new RegExp(`^([01xz])${signalDef.identifier}$`)
|
||||
new RegExp(`^([01xz])${escapedId}$`)
|
||||
);
|
||||
if (singleBitMatch) {
|
||||
values.push({ time: currentTime, value: singleBitMatch[1] });
|
||||
@ -715,7 +728,7 @@ function parseVCDSignals(content: string, maxSignals: number = 3) {
|
||||
} else {
|
||||
// 多比特信号
|
||||
const multiBitMatch = trimmedLine.match(
|
||||
new RegExp(`^b([01xz]+)\\s+${signalDef.identifier}$`)
|
||||
new RegExp(`^b([01xz]+)\\s+${escapedId}$`)
|
||||
);
|
||||
if (multiBitMatch) {
|
||||
values.push({ time: currentTime, value: multiBitMatch[1] });
|
||||
@ -728,12 +741,15 @@ function parseVCDSignals(content: string, maxSignals: number = 3) {
|
||||
}
|
||||
}
|
||||
|
||||
signals.push({
|
||||
name: signalDef.name,
|
||||
identifier: signalDef.identifier,
|
||||
width: signalDef.width,
|
||||
values: values,
|
||||
});
|
||||
// 只添加有值变化数据的信号
|
||||
if (values.length > 0) {
|
||||
signals.push({
|
||||
name: signalDef.name,
|
||||
identifier: signalDef.identifier,
|
||||
width: signalDef.width,
|
||||
values: values,
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("解析 VCD 信号数据失败:", error);
|
||||
|
||||
@ -59,7 +59,7 @@ export async function handleUserMessage(
|
||||
text: string,
|
||||
extensionPath?: string,
|
||||
mode?: RunMode,
|
||||
serviceTier?: ServiceTier // 新增:服务等级参数
|
||||
serviceTier?: ServiceTier // 新增:服务等级参数
|
||||
) {
|
||||
console.log("收到用户消息:", text);
|
||||
|
||||
@ -91,7 +91,14 @@ export async function handleUserMessage(
|
||||
// 尝试使用后端服务
|
||||
if (useBackendService && extensionPath) {
|
||||
try {
|
||||
await handleUserMessageWithBackend(panel, text, extensionPath, mode, undefined, serviceTier);
|
||||
await handleUserMessageWithBackend(
|
||||
panel,
|
||||
text,
|
||||
extensionPath,
|
||||
mode,
|
||||
undefined,
|
||||
serviceTier
|
||||
);
|
||||
return;
|
||||
} catch (error) {
|
||||
console.error("后端服务不可用:", error);
|
||||
@ -127,7 +134,7 @@ async function handleUserMessageWithBackend(
|
||||
extensionPath: string,
|
||||
mode?: RunMode,
|
||||
reuseTaskId?: string, // 可选,复用现有 taskId(用于 Plan 模式确认后继续执行)
|
||||
serviceTier?: ServiceTier // 新增:服务等级参数
|
||||
serviceTier?: ServiceTier // 新增:服务等级参数
|
||||
): Promise<void> {
|
||||
const historyManager = ChatHistoryManager.getInstance();
|
||||
|
||||
@ -137,10 +144,18 @@ async function handleUserMessageWithBackend(
|
||||
|
||||
// 创建或复用会话
|
||||
if (!currentSession || !currentSession.active) {
|
||||
currentSession = dialogManager.createSession(extensionPath, taskIdToUse || undefined);
|
||||
currentSession = dialogManager.createSession(
|
||||
extensionPath,
|
||||
taskIdToUse || undefined
|
||||
);
|
||||
// 保存 taskId 用于后续操作(如压缩)
|
||||
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,
|
||||
serviceTier // 传递服务等级
|
||||
serviceTier // 传递服务等级
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -218,8 +218,16 @@ export function getWaveformPreviewScript(): string {
|
||||
* 渲染波形预览信息
|
||||
*/
|
||||
function renderWaveformInfo(containerId, vcdInfo) {
|
||||
console.log('[renderWaveformInfo] 开始渲染波形, containerId:', containerId);
|
||||
console.log('[renderWaveformInfo] vcdInfo:', vcdInfo);
|
||||
|
||||
const container = document.getElementById(containerId);
|
||||
if (!container) return;
|
||||
if (!container) {
|
||||
console.error('[renderWaveformInfo] 找不到容器:', containerId);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[renderWaveformInfo] 找到容器,信号数量:', vcdInfo.signals?.length || 0);
|
||||
|
||||
// 清空容器
|
||||
container.innerHTML = '';
|
||||
@ -229,6 +237,7 @@ export function getWaveformPreviewScript(): string {
|
||||
waveformSvg.innerHTML = drawRealWaveform(vcdInfo.signals || []);
|
||||
|
||||
container.appendChild(waveformSvg);
|
||||
console.log('[renderWaveformInfo] 波形渲染完成');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user