add: 为逻辑分析仪添加了深度、预存储深度、通道组设置

This commit is contained in:
alivender
2025-07-31 13:14:23 +08:00
parent 3257a68407
commit 6b701658d1
8 changed files with 1012 additions and 718 deletions

View File

@@ -3678,6 +3678,92 @@ export class LogicAnalyzerClient {
return Promise.resolve<boolean>(null as any);
}
/**
* 设置深度、预采样深度、有效通道
* @param capture_length (optional) 深度
* @param pre_capture_length (optional) 预采样深度
* @param channel_div (optional) 有效通道(0-[1],1-[2],2-[4],3-[8],4-[16],5-[32])
* @return 操作结果
*/
setCaptureParams(capture_length: number | undefined, pre_capture_length: number | undefined, channel_div: AnalyzerChannelDiv | undefined, cancelToken?: CancelToken): Promise<boolean> {
let url_ = this.baseUrl + "/api/LogicAnalyzer/SetCaptureParams?";
if (capture_length === null)
throw new Error("The parameter 'capture_length' cannot be null.");
else if (capture_length !== undefined)
url_ += "capture_length=" + encodeURIComponent("" + capture_length) + "&";
if (pre_capture_length === null)
throw new Error("The parameter 'pre_capture_length' cannot be null.");
else if (pre_capture_length !== undefined)
url_ += "pre_capture_length=" + encodeURIComponent("" + pre_capture_length) + "&";
if (channel_div === null)
throw new Error("The parameter 'channel_div' cannot be null.");
else if (channel_div !== undefined)
url_ += "channel_div=" + encodeURIComponent("" + channel_div) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_: AxiosRequestConfig = {
method: "POST",
url: url_,
headers: {
"Accept": "application/json"
},
cancelToken
};
return this.instance.request(options_).catch((_error: any) => {
if (isAxiosError(_error) && _error.response) {
return _error.response;
} else {
throw _error;
}
}).then((_response: AxiosResponse) => {
return this.processSetCaptureParams(_response);
});
}
protected processSetCaptureParams(response: AxiosResponse): Promise<boolean> {
const status = response.status;
let _headers: any = {};
if (response.headers && typeof response.headers === "object") {
for (const k in response.headers) {
if (response.headers.hasOwnProperty(k)) {
_headers[k] = response.headers[k];
}
}
}
if (status === 200) {
const _responseText = response.data;
let result200: any = null;
let resultData200 = _responseText;
result200 = resultData200 !== undefined ? resultData200 : <any>null;
return Promise.resolve<boolean>(result200);
} else if (status === 400) {
const _responseText = response.data;
let result400: any = null;
let resultData400 = _responseText;
result400 = ProblemDetails.fromJS(resultData400);
return throwException("A server side error occurred.", status, _responseText, _headers, result400);
} else if (status === 500) {
const _responseText = response.data;
return throwException("A server side error occurred.", status, _responseText, _headers);
} else if (status === 401) {
const _responseText = response.data;
let result401: any = null;
let resultData401 = _responseText;
result401 = ProblemDetails.fromJS(resultData401);
return throwException("A server side error occurred.", status, _responseText, _headers, result401);
} else if (status !== 200 && status !== 204) {
const _responseText = response.data;
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}
return Promise.resolve<boolean>(null as any);
}
/**
* 批量配置捕获参数
* @param config 捕获配置
@@ -3827,10 +3913,15 @@ export class LogicAnalyzerClient {
/**
* 读取捕获数据
* @param capture_length (optional)
* @return 捕获的波形数据Base64编码
*/
getCaptureData( cancelToken?: CancelToken): Promise<string> {
let url_ = this.baseUrl + "/api/LogicAnalyzer/GetCaptureData";
getCaptureData(capture_length: number | undefined, cancelToken?: CancelToken): Promise<string> {
let url_ = this.baseUrl + "/api/LogicAnalyzer/GetCaptureData?";
if (capture_length === null)
throw new Error("The parameter 'capture_length' cannot be null.");
else if (capture_length !== undefined)
url_ += "capture_length=" + encodeURIComponent("" + capture_length) + "&";
url_ = url_.replace(/[?&]$/, "");
let options_: AxiosRequestConfig = {
@@ -7237,10 +7328,26 @@ export enum SignalValue {
SomeNumber = 7,
}
/** 逻辑分析仪有效通道数 */
export enum AnalyzerChannelDiv {
ONE = 0,
TWO = 1,
FOUR = 2,
EIGHT = 3,
XVI = 4,
XXXII = 5,
}
/** 捕获配置 */
export class CaptureConfig implements ICaptureConfig {
/** 全局触发模式 */
globalMode!: GlobalCaptureMode;
/** 捕获深度 */
captureLength!: number;
/** 预采样深度 */
preCaptureLength!: number;
/** 有效通道 */
channelDiv!: AnalyzerChannelDiv;
/** 信号触发配置列表 */
signalConfigs!: SignalTriggerConfig[];
@@ -7259,6 +7366,9 @@ export class CaptureConfig implements ICaptureConfig {
init(_data?: any) {
if (_data) {
this.globalMode = _data["globalMode"];
this.captureLength = _data["captureLength"];
this.preCaptureLength = _data["preCaptureLength"];
this.channelDiv = _data["channelDiv"];
if (Array.isArray(_data["signalConfigs"])) {
this.signalConfigs = [] as any;
for (let item of _data["signalConfigs"])
@@ -7277,6 +7387,9 @@ export class CaptureConfig implements ICaptureConfig {
toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
data["globalMode"] = this.globalMode;
data["captureLength"] = this.captureLength;
data["preCaptureLength"] = this.preCaptureLength;
data["channelDiv"] = this.channelDiv;
if (Array.isArray(this.signalConfigs)) {
data["signalConfigs"] = [];
for (let item of this.signalConfigs)
@@ -7290,6 +7403,12 @@ export class CaptureConfig implements ICaptureConfig {
export interface ICaptureConfig {
/** 全局触发模式 */
globalMode: GlobalCaptureMode;
/** 捕获深度 */
captureLength: number;
/** 预采样深度 */
preCaptureLength: number;
/** 有效通道 */
channelDiv: AnalyzerChannelDiv;
/** 信号触发配置列表 */
signalConfigs: SignalTriggerConfig[];
}