Compare commits
2 Commits
8070e03496
...
bcee42d8c1
Author | SHA1 | Date |
---|---|---|
|
bcee42d8c1 | |
|
9165c2e5f4 |
|
@ -240,6 +240,57 @@ const [useProvideLogicAnalyzer, useLogicAnalyzerState] = createInjectionState(
|
|||
logicData.value = data;
|
||||
};
|
||||
|
||||
const getCaptureData = async () => {
|
||||
try {
|
||||
const client = AuthManager.createAuthenticatedLogicAnalyzerClient();
|
||||
// 3. 获取捕获数据
|
||||
const base64Data = await client.getCaptureData();
|
||||
|
||||
// 4. 将base64数据转换为bytes
|
||||
const binaryString = atob(base64Data);
|
||||
const bytes = new Uint8Array(binaryString.length);
|
||||
for (let i = 0; i < binaryString.length; i++) {
|
||||
bytes[i] = binaryString.charCodeAt(i);
|
||||
}
|
||||
|
||||
// 5. 解析数据为8个通道的数字信号
|
||||
const sampleCount = bytes.length;
|
||||
const timeStepNs = SAMPLE_PERIOD_NS; // 每个采样点间隔200ns (1/5MHz)
|
||||
|
||||
// 创建时间轴(转换为合适的单位)
|
||||
const x = Array.from(
|
||||
{ length: sampleCount },
|
||||
(_, i) => (i * timeStepNs) / 1000,
|
||||
); // 转换为微秒
|
||||
|
||||
// 创建8个通道的数据
|
||||
const y: number[][] = Array.from(
|
||||
{ length: 8 },
|
||||
() => new Array(sampleCount),
|
||||
);
|
||||
|
||||
// 解析每个字节的8个位到对应通道
|
||||
for (let i = 0; i < sampleCount; i++) {
|
||||
const byte = bytes[i];
|
||||
for (let channel = 0; channel < 8; channel++) {
|
||||
// bit0对应ch0, bit1对应ch1, ..., bit7对应ch7
|
||||
y[channel][i] = (byte >> channel) & 1;
|
||||
}
|
||||
}
|
||||
|
||||
// 6. 设置逻辑数据
|
||||
const logicData: LogicDataType = {
|
||||
x,
|
||||
y,
|
||||
xUnit: "us", // 改为微秒单位
|
||||
};
|
||||
|
||||
setLogicData(logicData);
|
||||
} catch (error) {
|
||||
console.error("获取捕获数据失败:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const startCapture = async () => {
|
||||
// 检查是否有其他操作正在进行
|
||||
if (operationMutex.isLocked()) {
|
||||
|
@ -298,52 +349,9 @@ const [useProvideLogicAnalyzer, useLogicAnalyzerState] = createInjectionState(
|
|||
alert?.info("捕获已停止", 2000);
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. 获取捕获数据
|
||||
const base64Data = await client.getCaptureData();
|
||||
|
||||
// 4. 将base64数据转换为bytes
|
||||
const binaryString = atob(base64Data);
|
||||
const bytes = new Uint8Array(binaryString.length);
|
||||
for (let i = 0; i < binaryString.length; i++) {
|
||||
bytes[i] = binaryString.charCodeAt(i);
|
||||
}
|
||||
|
||||
// 5. 解析数据为8个通道的数字信号
|
||||
const sampleCount = bytes.length;
|
||||
const timeStepNs = SAMPLE_PERIOD_NS; // 每个采样点间隔200ns (1/5MHz)
|
||||
|
||||
// 创建时间轴(转换为合适的单位)
|
||||
const x = Array.from(
|
||||
{ length: sampleCount },
|
||||
(_, i) => (i * timeStepNs) / 1000,
|
||||
); // 转换为微秒
|
||||
|
||||
// 创建8个通道的数据
|
||||
const y: number[][] = Array.from(
|
||||
{ length: 8 },
|
||||
() => new Array(sampleCount),
|
||||
);
|
||||
|
||||
// 解析每个字节的8个位到对应通道
|
||||
for (let i = 0; i < sampleCount; i++) {
|
||||
const byte = bytes[i];
|
||||
for (let channel = 0; channel < 8; channel++) {
|
||||
// bit0对应ch0, bit1对应ch1, ..., bit7对应ch7
|
||||
y[channel][i] = (byte >> channel) & 1;
|
||||
}
|
||||
}
|
||||
|
||||
// 6. 设置逻辑数据
|
||||
const logicData: LogicDataType = {
|
||||
x,
|
||||
y,
|
||||
xUnit: "us", // 改为微秒单位
|
||||
};
|
||||
|
||||
setLogicData(logicData);
|
||||
|
||||
alert?.success(`捕获完成!获得 ${sampleCount} 个采样点`, 3000);
|
||||
|
||||
await getCaptureData();
|
||||
alert.success(`捕获完成!`, 3000);
|
||||
} catch (error) {
|
||||
console.error("捕获失败:", error);
|
||||
alert?.error(
|
||||
|
@ -357,19 +365,6 @@ const [useProvideLogicAnalyzer, useLogicAnalyzerState] = createInjectionState(
|
|||
};
|
||||
|
||||
const stopCapture = async () => {
|
||||
try {
|
||||
await forceCapture(); // 尝试强制捕获来停止当前捕获
|
||||
|
||||
// 设置捕获状态为false,这会使轮询停止
|
||||
isCapturing.value = false;
|
||||
|
||||
alert?.info("停止捕获...", 2000);
|
||||
} catch (error) {
|
||||
console.error("停止捕获失败:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const forceCapture = async () => {
|
||||
// 检查是否正在捕获
|
||||
if (!isCapturing.value) {
|
||||
alert.warn("当前没有正在进行的捕获操作", 2000);
|
||||
|
@ -384,10 +379,25 @@ const [useProvideLogicAnalyzer, useLogicAnalyzerState] = createInjectionState(
|
|||
if (!forceSuccess) {
|
||||
throw new Error("无法执行强制捕获");
|
||||
}
|
||||
|
||||
// 设置捕获状态为false,这会使轮询停止
|
||||
isCapturing.value = false;
|
||||
|
||||
alert.info("已停止强制捕获...", 2000);
|
||||
} catch (error) {
|
||||
console.error("捕获失败:", error);
|
||||
alert?.error(
|
||||
`捕获失败: ${error instanceof Error ? error.message : "未知错误"}`,
|
||||
console.error("停止捕获失败:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const forceCapture = async () => {
|
||||
try {
|
||||
await stopCapture();
|
||||
await getCaptureData();
|
||||
alert.success(`捕获完成!`, 3000);
|
||||
} catch (error) {
|
||||
console.error("强制捕获失败:", error);
|
||||
alert.error(
|
||||
`强制捕获失败: ${error instanceof Error ? error.message : "未知错误"}`,
|
||||
3000,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,31 +1,45 @@
|
|||
<template>
|
||||
<div class="motherboard-container" v-bind="$attrs" :style="{
|
||||
width: width + 'px',
|
||||
height: height + 'px',
|
||||
position: 'relative',
|
||||
}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" :width="width" :height="height" :viewBox="`0 0 800 600`"
|
||||
class="motherboard-svg">
|
||||
<image href="../equipments/svg/motherboard.svg" width="100%" height="100%" preserveAspectRatio="xMidYMid meet" />
|
||||
<div
|
||||
class="motherboard-container"
|
||||
v-bind="$attrs"
|
||||
:style="{
|
||||
width: width + 'px',
|
||||
height: height + 'px',
|
||||
position: 'relative',
|
||||
}"
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
:width="width"
|
||||
:height="height"
|
||||
:viewBox="`0 0 800 600`"
|
||||
class="motherboard-svg"
|
||||
>
|
||||
<image
|
||||
href="../equipments/svg/motherboard.svg"
|
||||
width="100%"
|
||||
height="100%"
|
||||
preserveAspectRatio="xMidYMid meet"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
<Teleport to="#ComponentCapabilities" v-if="selectecComponentID === props.componentId">
|
||||
<MotherBoardCaps :jtagAddr="props.boardAddr" :jtagPort="toNumber(props.boardPort)" :jtagFreq="jtagFreq"
|
||||
@change-jtag-freq="changeJtagFreq" />
|
||||
<Teleport
|
||||
to="#ComponentCapabilities"
|
||||
v-if="selectecComponentID === props.componentId"
|
||||
>
|
||||
<MotherBoardCaps :jtagFreq="jtagFreq" @change-jtag-freq="changeJtagFreq" />
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import MotherBoardCaps from "./MotherBoardCaps.vue";
|
||||
import { ref, computed, watchEffect, inject } from "vue";
|
||||
import { ref, computed, inject } from "vue";
|
||||
import { CanvasCurrentSelectedComponentID } from "../InjectKeys";
|
||||
import { toNumber } from "lodash";
|
||||
|
||||
// 主板特有属性
|
||||
export interface MotherBoardProps {
|
||||
size: number;
|
||||
boardAddr?: string;
|
||||
boardPort?: string;
|
||||
componentId?: string;
|
||||
}
|
||||
|
||||
|
@ -61,8 +75,6 @@ defineExpose({
|
|||
export function getDefaultProps(): MotherBoardProps {
|
||||
return {
|
||||
size: 1,
|
||||
boardAddr: "127.0.0.1",
|
||||
boardPort: "1234",
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -9,20 +9,7 @@
|
|||
IDCode: 0x{{ jtagIDCode.toString(16).padStart(8, "0").toUpperCase() }}
|
||||
</p>
|
||||
<button class="btn btn-circle w-6 h-6" :onclick="getIDCode">
|
||||
<svg
|
||||
class="icon opacity-70 fill-primary"
|
||||
viewBox="0 0 1024 1024"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
p-id="4865"
|
||||
width="200"
|
||||
height="200"
|
||||
>
|
||||
<path
|
||||
d="M894.481158 505.727133c0 49.589418-9.711176 97.705276-28.867468 143.007041-18.501376 43.74634-44.98454 83.031065-78.712713 116.759237-33.728172 33.728172-73.012897 60.211337-116.759237 78.712713-45.311998 19.156292-93.417623 28.877701-143.007041 28.877701s-97.695043-9.721409-142.996808-28.877701c-43.756573-18.501376-83.031065-44.98454-116.76947-78.712713-33.728172-33.728172-60.211337-73.012897-78.712713-116.759237-19.156292-45.301765-28.867468-93.417623-28.867468-143.007041 0-49.579185 9.711176-97.695043 28.867468-142.996808 18.501376-43.74634 44.98454-83.031065 78.712713-116.759237 33.738405-33.728172 73.012897-60.211337 116.76947-78.712713 45.301765-19.166525 93.40739-28.877701 142.996808-28.877701 52.925397 0 104.008842 11.010775 151.827941 32.745798 46.192042 20.977777 86.909395 50.79692 121.016191 88.608084 4.389984 4.860704 8.646937 9.854439 12.781094 14.97097l0-136.263453c0-11.307533 9.168824-20.466124 20.466124-20.466124 11.307533 0 20.466124 9.15859 20.466124 20.466124l0 183.64253c0 5.433756-2.148943 10.632151-5.986341 14.46955-3.847631 3.837398-9.046027 5.996574-14.479783 5.996574l-183.64253-0.020466c-11.307533 0-20.466124-9.168824-20.466124-20.466124 0-11.307533 9.168824-20.466124 20.466124-20.466124l132.293025 0.020466c-3.960195-4.952802-8.063653-9.782807-12.289907-14.479783-30.320563-33.605376-66.514903-60.098773-107.549481-78.753645-42.467207-19.289322-87.850837-29.072129-134.902456-29.072129-87.195921 0-169.172981 33.9533-230.816946 95.597265-61.654198 61.654198-95.597265 143.621025-95.597265 230.816946s33.943067 169.172981 95.597265 230.816946c61.643965 61.654198 143.621025 95.607498 230.816946 95.607498s169.172981-33.9533 230.816946-95.607498c61.654198-61.643965 95.597265-143.621025 95.597265-230.816946 0-11.2973 9.168824-20.466124 20.466124-20.466124C885.322567 485.261009 894.481158 494.429833 894.481158 505.727133z"
|
||||
p-id="4866"
|
||||
></path>
|
||||
</svg>
|
||||
<RefreshCcwIcon class="icon" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -102,10 +89,9 @@ import UploadCard from "@/components/UploadCard.vue";
|
|||
import { useDialogStore } from "@/stores/dialog";
|
||||
import { useEquipments } from "@/stores/equipments";
|
||||
import { computed, ref, watchEffect } from "vue";
|
||||
import { RefreshCcwIcon } from "lucide-vue-next";
|
||||
|
||||
interface CapsProps {
|
||||
jtagAddr?: string;
|
||||
jtagPort?: number;
|
||||
jtagFreq?: string;
|
||||
}
|
||||
|
||||
|
@ -179,11 +165,6 @@ async function toggleJtagBoundaryScan() {
|
|||
async function getIDCode(isQuiet: boolean = false) {
|
||||
jtagIDCode.value = await eqps.jtagGetIDCode(isQuiet);
|
||||
}
|
||||
|
||||
watchEffect(async () => {
|
||||
if (eqps.setAddr(props.jtagAddr) && eqps.setPort(props.jtagPort))
|
||||
getIDCode(true);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="postcss">
|
||||
|
|
Loading…
Reference in New Issue