feat:为边界扫描添加自动重复扫描

This commit is contained in:
alivender 2025-07-20 10:34:42 +08:00
parent 27c8ceb1db
commit 5103145d01
1 changed files with 21 additions and 4 deletions

View File

@ -22,6 +22,8 @@ export const useEquipments = defineStore("equipments", () => {
// Jtag
const jtagBitstream = ref<File>();
const jtagBoundaryScanFreq = ref(100);
const jtagBoundaryScanErrorCount = ref(0); // 边界扫描连续错误计数
const maxJtagBoundaryScanErrors = 5; // 最大允许连续错误次数
const jtagClientMutex = withTimeout(
new Mutex(),
1000,
@ -50,7 +52,11 @@ export const useEquipments = defineStore("equipments", () => {
// Watch
watchPostEffect(async () => {
if (true === enableJtagBoundaryScan.value) jtagBoundaryScan();
if (true === enableJtagBoundaryScan.value) {
// 重新启用时重置错误计数器
jtagBoundaryScanErrorCount.value = 0;
jtagBoundaryScan();
}
});
// Parse and Set
@ -109,10 +115,20 @@ export const useEquipments = defineStore("equipments", () => {
);
constrainsts.batchSetConstraintStates(portStates);
// 扫描成功,重置错误计数器
jtagBoundaryScanErrorCount.value = 0;
} catch (error) {
dialog.error("边界扫描发生错误");
console.error(error);
jtagBoundaryScanErrorCount.value++;
console.error(`边界扫描错误 (${jtagBoundaryScanErrorCount.value}/${maxJtagBoundaryScanErrors}):`, error);
// 如果错误次数超过最大允许次数,才停止扫描并显示错误
if (jtagBoundaryScanErrorCount.value >= maxJtagBoundaryScanErrors) {
dialog.error("边界扫描发生连续错误,已自动停止");
enableJtagBoundaryScan.value = false;
jtagBoundaryScanErrorCount.value = 0; // 重置错误计数器
}
} finally {
release();
@ -267,6 +283,7 @@ export const useEquipments = defineStore("equipments", () => {
enableJtagBoundaryScan,
jtagBitstream,
jtagBoundaryScanFreq,
jtagBoundaryScanErrorCount,
jtagClientMutex,
jtagUploadBitstream,
jtagDownloadBitstream,