style: pretty frontend chip vue

feat: fronten add boundary scan to APIClient
This commit is contained in:
SikongJueluo 2025-05-18 23:33:08 +08:00
parent 4885447c2b
commit 2a3ef1ea7d
2 changed files with 149 additions and 55 deletions

View File

@ -593,11 +593,10 @@ export class JtagClient {
* [TODO:description] * [TODO:description]
* @param address (optional) [TODO:parameter] * @param address (optional) [TODO:parameter]
* @param port (optional) [TODO:parameter] * @param port (optional) [TODO:parameter]
* @param portNum (optional) [TODO:parameter]
* @return [TODO:return] * @return [TODO:return]
*/ */
boundaryScan(address: string | undefined, port: number | undefined, portNum: number | undefined): Promise<boolean> { boundaryScanAllPorts(address: string | undefined, port: number | undefined): Promise<boolean> {
let url_ = this.baseUrl + "/api/Jtag/BoundaryScan?"; let url_ = this.baseUrl + "/api/Jtag/BoundaryScanAllPorts?";
if (address === null) if (address === null)
throw new Error("The parameter 'address' cannot be null."); throw new Error("The parameter 'address' cannot be null.");
else if (address !== undefined) else if (address !== undefined)
@ -606,10 +605,6 @@ export class JtagClient {
throw new Error("The parameter 'port' cannot be null."); throw new Error("The parameter 'port' cannot be null.");
else if (port !== undefined) else if (port !== undefined)
url_ += "port=" + encodeURIComponent("" + port) + "&"; url_ += "port=" + encodeURIComponent("" + port) + "&";
if (portNum === null)
throw new Error("The parameter 'portNum' cannot be null.");
else if (portNum !== undefined)
url_ += "portNum=" + encodeURIComponent("" + portNum) + "&";
url_ = url_.replace(/[?&]$/, ""); url_ = url_.replace(/[?&]$/, "");
let options_: RequestInit = { let options_: RequestInit = {
@ -620,11 +615,75 @@ export class JtagClient {
}; };
return this.http.fetch(url_, options_).then((_response: Response) => { return this.http.fetch(url_, options_).then((_response: Response) => {
return this.processBoundaryScan(_response); return this.processBoundaryScanAllPorts(_response);
}); });
} }
protected processBoundaryScan(response: Response): Promise<boolean> { protected processBoundaryScanAllPorts(response: Response): Promise<boolean> {
const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) {
return response.text().then((_responseText) => {
let result200: any = null;
let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
result200 = resultData200 !== undefined ? resultData200 : <any>null;
return result200;
});
} else if (status === 400) {
return response.text().then((_responseText) => {
let result400: any = null;
let resultData400 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
result400 = resultData400 !== undefined ? resultData400 : <any>null;
return throwException("A server side error occurred.", status, _responseText, _headers, result400);
});
} else if (status === 500) {
return response.text().then((_responseText) => {
let result500: any = null;
let resultData500 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
result500 = Exception.fromJS(resultData500);
return throwException("A server side error occurred.", status, _responseText, _headers, result500);
});
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<boolean>(null as any);
}
/**
* [TODO:description]
* @param address (optional) [TODO:parameter]
* @param port (optional) [TODO:parameter]
* @return [TODO:return]
*/
boundaryScanLogicalPorts(address: string | undefined, port: number | undefined): Promise<boolean> {
let url_ = this.baseUrl + "/api/Jtag/BoundaryScanLogicalPorts?";
if (address === null)
throw new Error("The parameter 'address' cannot be null.");
else if (address !== undefined)
url_ += "address=" + encodeURIComponent("" + address) + "&";
if (port === null)
throw new Error("The parameter 'port' cannot be null.");
else if (port !== undefined)
url_ += "port=" + encodeURIComponent("" + port) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_: RequestInit = {
method: "POST",
headers: {
"Accept": "application/json"
}
};
return this.http.fetch(url_, options_).then((_response: Response) => {
return this.processBoundaryScanLogicalPorts(_response);
});
}
protected processBoundaryScanLogicalPorts(response: Response): Promise<boolean> {
const status = response.status; const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); }; let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200) { if (status === 200) {
@ -659,7 +718,7 @@ export class JtagClient {
} }
} }
export class RemoteUpdaterClient { export class RemoteUpdateClient {
private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }; private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
private baseUrl: string; private baseUrl: string;
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined; protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;
@ -679,7 +738,7 @@ export class RemoteUpdaterClient {
* @return * @return
*/ */
uploadBitstreams(address: string | undefined, goldenBitream: FileParameter | null | undefined, bitstream1: FileParameter | null | undefined, bitstream2: FileParameter | null | undefined, bitstream3: FileParameter | null | undefined): Promise<boolean> { uploadBitstreams(address: string | undefined, goldenBitream: FileParameter | null | undefined, bitstream1: FileParameter | null | undefined, bitstream2: FileParameter | null | undefined, bitstream3: FileParameter | null | undefined): Promise<boolean> {
let url_ = this.baseUrl + "/api/RemoteUpdater/UploadBitstream?"; let url_ = this.baseUrl + "/api/RemoteUpdate/UploadBitstream?";
if (address === null) if (address === null)
throw new Error("The parameter 'address' cannot be null."); throw new Error("The parameter 'address' cannot be null.");
else if (address !== undefined) else if (address !== undefined)
@ -742,7 +801,7 @@ export class RemoteUpdaterClient {
* @param bitstreamNum (optional) * @param bitstreamNum (optional)
*/ */
updateBitstream(address: string | undefined, port: number | undefined, bitstreamNum: number | undefined): Promise<boolean> { updateBitstream(address: string | undefined, port: number | undefined, bitstreamNum: number | undefined): Promise<boolean> {
let url_ = this.baseUrl + "/api/RemoteUpdater/DownloadBitstream?"; let url_ = this.baseUrl + "/api/RemoteUpdate/DownloadBitstream?";
if (address === null) if (address === null)
throw new Error("The parameter 'address' cannot be null."); throw new Error("The parameter 'address' cannot be null.");
else if (address !== undefined) else if (address !== undefined)
@ -810,7 +869,7 @@ export class RemoteUpdaterClient {
* @return * @return
*/ */
downloadMultiBitstreams(address: string | undefined, port: number | undefined, bitstreamNum: number | null | undefined): Promise<number> { downloadMultiBitstreams(address: string | undefined, port: number | undefined, bitstreamNum: number | null | undefined): Promise<number> {
let url_ = this.baseUrl + "/api/RemoteUpdater/DownloadMultiBitstreams?"; let url_ = this.baseUrl + "/api/RemoteUpdate/DownloadMultiBitstreams?";
if (address === null) if (address === null)
throw new Error("The parameter 'address' cannot be null."); throw new Error("The parameter 'address' cannot be null.");
else if (address !== undefined) else if (address !== undefined)
@ -876,7 +935,7 @@ export class RemoteUpdaterClient {
* @return * @return
*/ */
hotResetBitstream(address: string | undefined, port: number | undefined, bitstreamNum: number | undefined): Promise<boolean> { hotResetBitstream(address: string | undefined, port: number | undefined, bitstreamNum: number | undefined): Promise<boolean> {
let url_ = this.baseUrl + "/api/RemoteUpdater/HotResetBitstream?"; let url_ = this.baseUrl + "/api/RemoteUpdate/HotResetBitstream?";
if (address === null) if (address === null)
throw new Error("The parameter 'address' cannot be null."); throw new Error("The parameter 'address' cannot be null.");
else if (address !== undefined) else if (address !== undefined)
@ -943,7 +1002,7 @@ export class RemoteUpdaterClient {
* @return [TODO:return] * @return [TODO:return]
*/ */
getFirmwareVersion(address: string | undefined, port: number | undefined): Promise<number> { getFirmwareVersion(address: string | undefined, port: number | undefined): Promise<number> {
let url_ = this.baseUrl + "/api/RemoteUpdater/GetFirmwareVersion?"; let url_ = this.baseUrl + "/api/RemoteUpdate/GetFirmwareVersion?";
if (address === null) if (address === null)
throw new Error("The parameter 'address' cannot be null."); throw new Error("The parameter 'address' cannot be null.");
else if (address !== undefined) else if (address !== undefined)
@ -1240,6 +1299,55 @@ export class DDSClient {
} }
} }
export class BsdlParserClient {
private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
private baseUrl: string;
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;
constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
this.http = http ? http : window as any;
this.baseUrl = baseUrl ?? "http://localhost:5000";
}
getBoundaryLogicalPorts(): Promise<FileResponse> {
let url_ = this.baseUrl + "/api/BsdlParser/GetBoundaryLogicalPorts";
url_ = url_.replace(/[?&]$/, "");
let options_: RequestInit = {
method: "GET",
headers: {
"Accept": "application/octet-stream"
}
};
return this.http.fetch(url_, options_).then((_response: Response) => {
return this.processGetBoundaryLogicalPorts(_response);
});
}
protected processGetBoundaryLogicalPorts(response: Response): Promise<FileResponse> {
const status = response.status;
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
if (status === 200 || status === 206) {
const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
let fileNameMatch = contentDisposition ? /filename\*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/g.exec(contentDisposition) : undefined;
let fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[3] || fileNameMatch[2] : undefined;
if (fileName) {
fileName = decodeURIComponent(fileName);
} else {
fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
}
return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
} else if (status !== 200 && status !== 204) {
return response.text().then((_responseText) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
});
}
return Promise.resolve<FileResponse>(null as any);
}
}
export class DataClient { export class DataClient {
private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }; private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
private baseUrl: string; private baseUrl: string;
@ -1710,4 +1818,4 @@ function throwException(message: string, status: number, response: string, heade
throw result; throw result;
else else
throw new ApiException(message, status, response, headers, null); throw new ApiException(message, status, response, headers, null);
} }

View File

@ -1,36 +1,22 @@
<template> <template>
<div class="chip-container" :style="{ width: width + 'px', height: height + 'px', position: 'relative' }"> <svg <div class="chip-container" :style="{ width: width + 'px', height: height + 'px', position: 'relative' }"> <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" :width="width" :height="height" viewBox="0 0 400 400" class="fbg676-chip">
:width="width" <!-- 芯片外边框 - 用多段path代替rect这样可以实现缺角 -->
:height="height" <path d="M30,0 H390 Q400,0 400,10 V390 Q400,400 390,400 H10 Q0,400 0,390 V30 L30,0 Z" fill="#1C4E2D" />
viewBox="0 0 400 400"
class="fbg676-chip"
> <!-- 芯片外边框 - 用多段path代替rect这样可以实现缺角 -->
<path
d="M30,0 H390 Q400,0 400,10 V390 Q400,400 390,400 H10 Q0,400 0,390 V30 L30,0 Z"
fill="#1C4E2D"
/>
<!-- 芯片内层 - 增大尺寸 --> <!-- 芯片内层 - 增大尺寸 -->
<rect width="280" height="280" x="60" y="60" fill="#0F1211" rx="2" ry="2" /> <rect width="280" height="280" x="60" y="60" fill="#0F1211" rx="2" ry="2" />
</svg> </svg>
<!-- 渲染芯片引脚 --> <div v-for="pin in computedPins" :key="pin.pinId" <!-- 渲染芯片引脚 -->
:style="{ <div v-for="pin in computedPins" :key="pin.pinId" :style="{
position: 'absolute', position: 'absolute',
left: `${(pin.x || 0) * props.size * 0.37}px`, left: `${(pin.x || 0) * props.size * 0.37}px`,
top: `${(pin.y || 0) * props.size * 0.37}px`, top: `${(pin.y || 0) * props.size * 0.37}px`,
transform: 'translate(-50%, -50%)' transform: 'translate(-50%, -50%)'
}" }" :data-pin-wrapper="`${pin.pinId}`" :data-pin-x="`${(pin.x || 0) * props.size * 0.37}`"
:data-pin-wrapper="`${pin.pinId}`" :data-pin-y="`${(pin.y || 0) * props.size * 0.37}`">
:data-pin-x="`${(pin.x || 0) * props.size * 0.37}`" <Pin :ref="el => { if (el) pinRefs[pin.pinId] = el }" :label="pin.pinId" :constraint="pin.constraint"
:data-pin-y="`${(pin.y || 0) * props.size * 0.37}`"> <Pin :pinId="pin.pinId" :size="0.35" @pin-click="$emit('pin-click', $event)" />
:ref="el => { if(el) pinRefs[pin.pinId] = el }"
:label="pin.pinId"
:constraint="pin.constraint"
:pinId="pin.pinId"
:size="0.35"
@pin-click="$emit('pin-click', $event)"
/>
</div> </div>
</div> </div>
</template> </template>
@ -74,12 +60,12 @@ const computedPins = computed(() => {
const yEnd = 400 - margin; const yEnd = 400 - margin;
const xStep = (xEnd - xStart) / (pinColumns - 1); const xStep = (xEnd - xStart) / (pinColumns - 1);
const yStep = (yEnd - yStart) / (pinRows - 1); const yStep = (yEnd - yStart) / (pinRows - 1);
// pins // pins
if (props.pins && props.pins.length > 0) { if (props.pins && props.pins.length > 0) {
// pins // pins
const mergedPins = [...props.pins]; const mergedPins = [...props.pins];
// xyxy // xyxy
for (let i = 0; i < mergedPins.length; i++) { for (let i = 0; i < mergedPins.length; i++) {
const pin = mergedPins[i]; const pin = mergedPins[i];
@ -87,19 +73,19 @@ const computedPins = computed(() => {
if (pin.x === undefined || pin.y === undefined) { if (pin.x === undefined || pin.y === undefined) {
const row = Math.floor(i / pinColumns); const row = Math.floor(i / pinColumns);
const col = i % pinColumns; const col = i % pinColumns;
pin.x = xStart + col * xStep; pin.x = xStart + col * xStep;
pin.y = yStart + row * yStep; pin.y = yStart + row * yStep;
} }
} }
return mergedPins; return mergedPins;
} }
// 676BGA // 676BGA
const pins = []; const pins = [];
let pinIndex = 0; let pinIndex = 0;
// BGA // BGA
for (let row = 0; row < pinRows; row++) { for (let row = 0; row < pinRows; row++) {
for (let col = 0; col < pinColumns; col++) { for (let col = 0; col < pinColumns; col++) {
pins.push({ pins.push({
@ -110,7 +96,7 @@ const computedPins = computed(() => {
}); });
} }
} }
return pins; return pins;
}); });
@ -120,17 +106,17 @@ defineExpose({
direction: 'inout', direction: 'inout',
type: 'digital', type: 'digital',
pins: computedPins.value pins: computedPins.value
}), }),
getPinPosition: (pinId: string) => { getPinPosition: (pinId: string) => {
// ID // ID
if (computedPins.value && computedPins.value.length > 0) { if (computedPins.value && computedPins.value.length > 0) {
const customPin = computedPins.value.find(p => p.pinId === pinId); const customPin = computedPins.value.find(p => p.pinId === pinId);
if (customPin && customPin.x !== undefined && customPin.y !== undefined) { if (customPin && customPin.x !== undefined && customPin.y !== undefined) {
// 0.37 // 0.37
const scaledX = customPin.x * props.size * 0.37; const scaledX = customPin.x * props.size * 0.37;
const scaledY = customPin.y * props.size * 0.37; const scaledY = customPin.y * props.size * 0.37;
return { return {
x: scaledX, x: scaledX,
y: scaledY y: scaledY