//----------------------
// <auto-generated>
//     Generated using the NSwag toolchain v14.4.0.0 (NJsonSchema v11.3.2.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
// </auto-generated>
//----------------------

/* tslint:disable */
/* eslint-disable */
// ReSharper disable InconsistentNaming

import axios, { AxiosError, type AxiosInstance, type AxiosRequestConfig, type AxiosResponse, type CancelToken } from 'axios';

export class Client {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    getSignalrDevSpec_json( cancelToken?: CancelToken): Promise<void> {
        let url_ = this.baseUrl + "/signalr-dev/spec.json";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            url: url_,
            headers: {
            },
            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.processGetSignalrDevSpec_json(_response);
        });
    }

    protected processGetSignalrDevSpec_json(response: AxiosResponse): Promise<void> {
        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;
            return Promise.resolve<void>(null as any);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<void>(null as any);
    }

    getGetAPIClientCode( cancelToken?: CancelToken): Promise<void> {
        let url_ = this.baseUrl + "/GetAPIClientCode";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            url: url_,
            headers: {
            },
            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.processGetGetAPIClientCode(_response);
        });
    }

    protected processGetGetAPIClientCode(response: AxiosResponse): Promise<void> {
        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;
            return Promise.resolve<void>(null as any);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<void>(null as any);
    }
}

export class VideoStreamClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    /**
     * 获取 HTTP 视频流服务状态
     * @return 服务状态信息
     */
    getServiceStatus( cancelToken?: CancelToken): Promise<VideoStreamServiceStatus> {
        let url_ = this.baseUrl + "/api/VideoStream/ServiceStatus";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetServiceStatus(_response);
        });
    }

    protected processGetServiceStatus(response: AxiosResponse): Promise<VideoStreamServiceStatus> {
        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 = VideoStreamServiceStatus.fromJS(resultData200);
            return Promise.resolve<VideoStreamServiceStatus>(result200);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<VideoStreamServiceStatus>(null as any);
    }

    myEndpoint( cancelToken?: CancelToken): Promise<VideoStreamEndpoint> {
        let url_ = this.baseUrl + "/api/VideoStream/MyEndpoint";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processMyEndpoint(_response);
        });
    }

    protected processMyEndpoint(response: AxiosResponse): Promise<VideoStreamEndpoint> {
        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 = VideoStreamEndpoint.fromJS(resultData200);
            return Promise.resolve<VideoStreamEndpoint>(result200);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<VideoStreamEndpoint>(null as any);
    }

    /**
     * 测试 HTTP 视频流连接
     * @return 连接测试结果
     */
    testConnection( cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/VideoStream/TestConnection";
        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.processTestConnection(_response);
        });
    }

    protected processTestConnection(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 === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } 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);
    }

    setVideoStreamEnable(enable: boolean | undefined, cancelToken?: CancelToken): Promise<any> {
        let url_ = this.baseUrl + "/api/VideoStream/SetVideoStreamEnable?";
        if (enable === null)
            throw new Error("The parameter 'enable' cannot be null.");
        else if (enable !== undefined)
            url_ += "enable=" + encodeURIComponent("" + enable) + "&";
        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.processSetVideoStreamEnable(_response);
        });
    }

    protected processSetVideoStreamEnable(response: AxiosResponse): Promise<any> {
        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<any>(result200);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
                result500 = resultData500 !== undefined ? resultData500 : <any>null;
    
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<any>(null as any);
    }

    /**
     * 设置视频流分辨率
     * @param request 分辨率配置请求
     * @return 设置结果
     */
    setResolution(request: ResolutionConfigRequest, cancelToken?: CancelToken): Promise<any> {
        let url_ = this.baseUrl + "/api/VideoStream/Resolution";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(request);

        let options_: AxiosRequestConfig = {
            data: content_,
            method: "POST",
            url: url_,
            headers: {
                "Content-Type": "application/json",
                "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.processSetResolution(_response);
        });
    }

    protected processSetResolution(response: AxiosResponse): Promise<any> {
        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<any>(result200);

        } else if (status === 400) {
            const _responseText = response.data;
            let result400: any = null;
            let resultData400  = _responseText;
                result400 = resultData400 !== undefined ? resultData400 : <any>null;
    
            return throwException("A server side error occurred.", status, _responseText, _headers, result400);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
                result500 = resultData500 !== undefined ? resultData500 : <any>null;
    
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<any>(null as any);
    }

    /**
     * 获取支持的分辨率列表
     * @return 支持的分辨率列表
     */
    getSupportedResolutions( cancelToken?: CancelToken): Promise<AvailableResolutionsResponse[]> {
        let url_ = this.baseUrl + "/api/VideoStream/SupportedResolutions";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetSupportedResolutions(_response);
        });
    }

    protected processGetSupportedResolutions(response: AxiosResponse): Promise<AvailableResolutionsResponse[]> {
        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;
            if (Array.isArray(resultData200)) {
                result200 = [] as any;
                for (let item of resultData200)
                    result200!.push(AvailableResolutionsResponse.fromJS(item));
            }
            else {
                result200 = <any>null;
            }
            return Promise.resolve<AvailableResolutionsResponse[]>(result200);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
                result500 = resultData500 !== undefined ? resultData500 : <any>null;
    
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<AvailableResolutionsResponse[]>(null as any);
    }

    /**
     * 初始化摄像头自动对焦功能
     * @return 初始化结果
     */
    initAutoFocus( cancelToken?: CancelToken): Promise<any> {
        let url_ = this.baseUrl + "/api/VideoStream/InitAutoFocus";
        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.processInitAutoFocus(_response);
        });
    }

    protected processInitAutoFocus(response: AxiosResponse): Promise<any> {
        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<any>(result200);

        } else if (status === 400) {
            const _responseText = response.data;
            let result400: any = null;
            let resultData400  = _responseText;
                result400 = resultData400 !== undefined ? resultData400 : <any>null;
    
            return throwException("A server side error occurred.", status, _responseText, _headers, result400);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
                result500 = resultData500 !== undefined ? resultData500 : <any>null;
    
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<any>(null as any);
    }

    /**
     * 执行自动对焦
     * @return 对焦结果
     */
    autoFocus( cancelToken?: CancelToken): Promise<any> {
        let url_ = this.baseUrl + "/api/VideoStream/AutoFocus";
        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.processAutoFocus(_response);
        });
    }

    protected processAutoFocus(response: AxiosResponse): Promise<any> {
        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<any>(result200);

        } else if (status === 400) {
            const _responseText = response.data;
            let result400: any = null;
            let resultData400  = _responseText;
                result400 = resultData400 !== undefined ? resultData400 : <any>null;
    
            return throwException("A server side error occurred.", status, _responseText, _headers, result400);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
                result500 = resultData500 !== undefined ? resultData500 : <any>null;
    
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<any>(null as any);
    }

    /**
     * 配置摄像头连接参数
     * @return 配置结果
     */
    configureCamera( cancelToken?: CancelToken): Promise<any> {
        let url_ = this.baseUrl + "/api/VideoStream/ConfigureCamera";
        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.processConfigureCamera(_response);
        });
    }

    protected processConfigureCamera(response: AxiosResponse): Promise<any> {
        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<any>(result200);

        } else if (status === 400) {
            const _responseText = response.data;
            let result400: any = null;
            let resultData400  = _responseText;
                result400 = resultData400 !== undefined ? resultData400 : <any>null;
    
            return throwException("A server side error occurred.", status, _responseText, _headers, result400);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<any>(null as any);
    }
}

export class BsdlParserClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    /**
     * [TODO:description]
     * @return [TODO:return]
     */
    getBoundaryLogicalPorts( cancelToken?: CancelToken): Promise<FileResponse | null> {
        let url_ = this.baseUrl + "/api/BsdlParser/GetBoundaryLogicalPorts";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            responseType: "blob",
            method: "GET",
            url: url_,
            headers: {
                "Accept": "application/octet-stream"
            },
            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.processGetBoundaryLogicalPorts(_response);
        });
    }

    protected processGetBoundaryLogicalPorts(response: AxiosResponse): Promise<FileResponse | null> {
        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 || status === 206) {
            const contentDisposition = response.headers ? response.headers["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 Promise.resolve({ fileName: fileName, status: status, data: new Blob([response.data], { type: response.headers["content-type"] }), headers: _headers });
        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<FileResponse | null>(null as any);
    }
}

export class DataClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    /**
     * 用户登录，获取 JWT 令牌
     * @param name (optional) 用户名
     * @param password (optional) 用户密码
     * @return JWT 令牌字符串
     */
    login(name: string | undefined, password: string | undefined, cancelToken?: CancelToken): Promise<string> {
        let url_ = this.baseUrl + "/api/Data/Login?";
        if (name === null)
            throw new Error("The parameter 'name' cannot be null.");
        else if (name !== undefined)
            url_ += "name=" + encodeURIComponent("" + name) + "&";
        if (password === null)
            throw new Error("The parameter 'password' cannot be null.");
        else if (password !== undefined)
            url_ += "password=" + encodeURIComponent("" + password) + "&";
        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.processLogin(_response);
        });
    }

    protected processLogin(response: AxiosResponse): Promise<string> {
        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<string>(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 !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<string>(null as any);
    }

    /**
     * 测试用户认证，需携带有效 JWT
     * @return 认证成功信息
     */
    testAuth( cancelToken?: CancelToken): Promise<string> {
        let url_ = this.baseUrl + "/api/Data/TestAuth";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processTestAuth(_response);
        });
    }

    protected processTestAuth(response: AxiosResponse): Promise<string> {
        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<string>(result200);

        } 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<string>(null as any);
    }

    /**
     * 测试管理员用户认证，需携带有效 JWT
     * @return 认证成功信息
     */
    testAdminAuth( cancelToken?: CancelToken): Promise<string> {
        let url_ = this.baseUrl + "/api/Data/TestAdminAuth";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processTestAdminAuth(_response);
        });
    }

    protected processTestAdminAuth(response: AxiosResponse): Promise<string> {
        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<string>(result200);

        } 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<string>(null as any);
    }

    /**
     * 获取当前用户信息
     * @return 用户信息，包括ID、用户名、邮箱和板卡ID
     */
    getUserInfo( cancelToken?: CancelToken): Promise<UserInfo> {
        let url_ = this.baseUrl + "/api/Data/GetUserInfo";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetUserInfo(_response);
        });
    }

    protected processGetUserInfo(response: AxiosResponse): Promise<UserInfo> {
        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 = UserInfo.fromJS(resultData200);
            return Promise.resolve<UserInfo>(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<UserInfo>(null as any);
    }

    /**
     * 注册新用户
     * @param name (optional) 用户名（不超过255个字符）
     * @param email (optional) 邮箱地址
     * @param password (optional) 用户密码
     * @return 操作结果，成功返回 true，失败返回错误信息
     */
    signUpUser(name: string | undefined, email: string | undefined, password: string | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/Data/SignUpUser?";
        if (name === null)
            throw new Error("The parameter 'name' cannot be null.");
        else if (name !== undefined)
            url_ += "name=" + encodeURIComponent("" + name) + "&";
        if (email === null)
            throw new Error("The parameter 'email' cannot be null.");
        else if (email !== undefined)
            url_ += "email=" + encodeURIComponent("" + email) + "&";
        if (password === null)
            throw new Error("The parameter 'password' cannot be null.");
        else if (password !== undefined)
            url_ += "password=" + encodeURIComponent("" + password) + "&";
        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.processSignUpUser(_response);
        });
    }

    protected processSignUpUser(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 !== 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 durationHours (optional) 绑定持续时间（小时），默认为1小时
     */
    getAvailableBoard(durationHours: number | undefined, cancelToken?: CancelToken): Promise<Board> {
        let url_ = this.baseUrl + "/api/Data/GetAvailableBoard?";
        if (durationHours === null)
            throw new Error("The parameter 'durationHours' cannot be null.");
        else if (durationHours !== undefined)
            url_ += "durationHours=" + encodeURIComponent("" + durationHours) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetAvailableBoard(_response);
        });
    }

    protected processGetAvailableBoard(response: AxiosResponse): Promise<Board> {
        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 = Board.fromJS(resultData200);
            return Promise.resolve<Board>(result200);

        } else if (status === 404) {
            const _responseText = response.data;
            let result404: any = null;
            let resultData404  = _responseText;
            result404 = ProblemDetails.fromJS(resultData404);
            return throwException("A server side error occurred.", status, _responseText, _headers, result404);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<Board>(null as any);
    }

    /**
     * 解除当前用户绑定的实验板（普通用户权限）
     */
    unbindBoard( cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/Data/UnbindBoard";
        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.processUnbindBoard(_response);
        });
    }

    protected processUnbindBoard(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 !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<boolean>(null as any);
    }

    /**
     * 用户根据实验板ID获取实验板信息（普通用户权限）
     * @param id (optional) 
     */
    getBoardByID(id: string | undefined, cancelToken?: CancelToken): Promise<Board> {
        let url_ = this.baseUrl + "/api/Data/GetBoardByID?";
        if (id === null)
            throw new Error("The parameter 'id' cannot be null.");
        else if (id !== undefined)
            url_ += "id=" + encodeURIComponent("" + id) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetBoardByID(_response);
        });
    }

    protected processGetBoardByID(response: AxiosResponse): Promise<Board> {
        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 = Board.fromJS(resultData200);
            return Promise.resolve<Board>(result200);

        } else if (status === 404) {
            const _responseText = response.data;
            let result404: any = null;
            let resultData404  = _responseText;
            result404 = ProblemDetails.fromJS(resultData404);
            return throwException("A server side error occurred.", status, _responseText, _headers, result404);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<Board>(null as any);
    }

    /**
     * 新增板子（管理员权限）
     * @param name (optional) 
     */
    addBoard(name: string | undefined, cancelToken?: CancelToken): Promise<string> {
        let url_ = this.baseUrl + "/api/Data/AddBoard?";
        if (name === null)
            throw new Error("The parameter 'name' cannot be null.");
        else if (name !== undefined)
            url_ += "name=" + encodeURIComponent("" + name) + "&";
        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.processAddBoard(_response);
        });
    }

    protected processAddBoard(response: AxiosResponse): Promise<string> {
        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<string>(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 !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<string>(null as any);
    }

    /**
     * 删除板子（管理员权限）
     * @param id (optional) 
     */
    deleteBoard(id: string | undefined, cancelToken?: CancelToken): Promise<number> {
        let url_ = this.baseUrl + "/api/Data/DeleteBoard?";
        if (id === null)
            throw new Error("The parameter 'id' cannot be null.");
        else if (id !== undefined)
            url_ += "id=" + encodeURIComponent("" + id) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "DELETE",
            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.processDeleteBoard(_response);
        });
    }

    protected processDeleteBoard(response: AxiosResponse): Promise<number> {
        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<number>(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 !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<number>(null as any);
    }

    /**
     * 获取全部板子（管理员权限）
     */
    getAllBoards( cancelToken?: CancelToken): Promise<Board[]> {
        let url_ = this.baseUrl + "/api/Data/GetAllBoards";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetAllBoards(_response);
        });
    }

    protected processGetAllBoards(response: AxiosResponse): Promise<Board[]> {
        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;
            if (Array.isArray(resultData200)) {
                result200 = [] as any;
                for (let item of resultData200)
                    result200!.push(Board.fromJS(item));
            }
            else {
                result200 = <any>null;
            }
            return Promise.resolve<Board[]>(result200);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<Board[]>(null as any);
    }

    /**
     * 更新板卡名称（管理员权限）
     * @param boardId (optional) 
     * @param newName (optional) 
     */
    updateBoardName(boardId: string | undefined, newName: string | undefined, cancelToken?: CancelToken): Promise<number> {
        let url_ = this.baseUrl + "/api/Data/UpdateBoardName?";
        if (boardId === null)
            throw new Error("The parameter 'boardId' cannot be null.");
        else if (boardId !== undefined)
            url_ += "boardId=" + encodeURIComponent("" + boardId) + "&";
        if (newName === null)
            throw new Error("The parameter 'newName' cannot be null.");
        else if (newName !== undefined)
            url_ += "newName=" + encodeURIComponent("" + newName) + "&";
        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.processUpdateBoardName(_response);
        });
    }

    protected processUpdateBoardName(response: AxiosResponse): Promise<number> {
        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<number>(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 !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<number>(null as any);
    }

    /**
     * 更新板卡状态（管理员权限）
     * @param boardId (optional) 
     * @param newStatus (optional) 
     */
    updateBoardStatus(boardId: string | undefined, newStatus: BoardStatus | undefined, cancelToken?: CancelToken): Promise<number> {
        let url_ = this.baseUrl + "/api/Data/UpdateBoardStatus?";
        if (boardId === null)
            throw new Error("The parameter 'boardId' cannot be null.");
        else if (boardId !== undefined)
            url_ += "boardId=" + encodeURIComponent("" + boardId) + "&";
        if (newStatus === null)
            throw new Error("The parameter 'newStatus' cannot be null.");
        else if (newStatus !== undefined)
            url_ += "newStatus=" + encodeURIComponent("" + newStatus) + "&";
        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.processUpdateBoardStatus(_response);
        });
    }

    protected processUpdateBoardStatus(response: AxiosResponse): Promise<number> {
        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<number>(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 !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<number>(null as any);
    }
}

export class DDSClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    /**
     * [TODO:description]
     * @param address (optional) [TODO:parameter]
     * @param port (optional) [TODO:parameter]
     * @param channelNum (optional) [TODO:parameter]
     * @param waveNum (optional) [TODO:parameter]
     * @return [TODO:return]
     */
    setWaveNum(address: string | undefined, port: number | undefined, channelNum: number | undefined, waveNum: number | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/DDS/SetWaveNum?";
        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) + "&";
        if (channelNum === null)
            throw new Error("The parameter 'channelNum' cannot be null.");
        else if (channelNum !== undefined)
            url_ += "channelNum=" + encodeURIComponent("" + channelNum) + "&";
        if (waveNum === null)
            throw new Error("The parameter 'waveNum' cannot be null.");
        else if (waveNum !== undefined)
            url_ += "waveNum=" + encodeURIComponent("" + waveNum) + "&";
        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.processSetWaveNum(_response);
        });
    }

    protected processSetWaveNum(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 = ArgumentException.fromJS(resultData400);
            return throwException("A server side error occurred.", status, _responseText, _headers, result400);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } 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);
    }

    /**
     * [TODO:description]
     * @param address (optional) [TODO:parameter]
     * @param port (optional) [TODO:parameter]
     * @param channelNum (optional) [TODO:parameter]
     * @param waveNum (optional) [TODO:parameter]
     * @param step (optional) [TODO:parameter]
     * @return [TODO:return]
     */
    setFreq(address: string | undefined, port: number | undefined, channelNum: number | undefined, waveNum: number | undefined, step: number | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/DDS/SetFreq?";
        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) + "&";
        if (channelNum === null)
            throw new Error("The parameter 'channelNum' cannot be null.");
        else if (channelNum !== undefined)
            url_ += "channelNum=" + encodeURIComponent("" + channelNum) + "&";
        if (waveNum === null)
            throw new Error("The parameter 'waveNum' cannot be null.");
        else if (waveNum !== undefined)
            url_ += "waveNum=" + encodeURIComponent("" + waveNum) + "&";
        if (step === null)
            throw new Error("The parameter 'step' cannot be null.");
        else if (step !== undefined)
            url_ += "step=" + encodeURIComponent("" + step) + "&";
        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.processSetFreq(_response);
        });
    }

    protected processSetFreq(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 = ArgumentException.fromJS(resultData400);
            return throwException("A server side error occurred.", status, _responseText, _headers, result400);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } 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);
    }

    /**
     * [TODO:description]
     * @param address (optional) [TODO:parameter]
     * @param port (optional) [TODO:parameter]
     * @param channelNum (optional) [TODO:parameter]
     * @param waveNum (optional) [TODO:parameter]
     * @param phase (optional) [TODO:parameter]
     * @return [TODO:return]
     */
    setPhase(address: string | undefined, port: number | undefined, channelNum: number | undefined, waveNum: number | undefined, phase: number | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/DDS/SetPhase?";
        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) + "&";
        if (channelNum === null)
            throw new Error("The parameter 'channelNum' cannot be null.");
        else if (channelNum !== undefined)
            url_ += "channelNum=" + encodeURIComponent("" + channelNum) + "&";
        if (waveNum === null)
            throw new Error("The parameter 'waveNum' cannot be null.");
        else if (waveNum !== undefined)
            url_ += "waveNum=" + encodeURIComponent("" + waveNum) + "&";
        if (phase === null)
            throw new Error("The parameter 'phase' cannot be null.");
        else if (phase !== undefined)
            url_ += "phase=" + encodeURIComponent("" + phase) + "&";
        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.processSetPhase(_response);
        });
    }

    protected processSetPhase(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 = ArgumentException.fromJS(resultData400);
            return throwException("A server side error occurred.", status, _responseText, _headers, result400);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } 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);
    }
}

export class DebuggerClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    /**
     * 设置指定信号线的捕获模式
     * @param wireNum (optional) 信号线编号（0~511）
     * @param mode (optional) 捕获模式
     */
    setMode(wireNum: number | undefined, mode: CaptureMode | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/Debugger/SetMode?";
        if (wireNum === null)
            throw new Error("The parameter 'wireNum' cannot be null.");
        else if (wireNum !== undefined)
            url_ += "wireNum=" + encodeURIComponent("" + wireNum) + "&";
        if (mode === null)
            throw new Error("The parameter 'mode' cannot be null.");
        else if (mode !== undefined)
            url_ += "mode=" + encodeURIComponent("" + mode) + "&";
        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.processSetMode(_response);
        });
    }

    protected processSetMode(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 调试器配置信息，包含所有通道的捕获模式设置
     */
    setChannelsMode(config: DebuggerConfig, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/Debugger/SetChannelsMode";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(config);

        let options_: AxiosRequestConfig = {
            data: content_,
            method: "POST",
            url: url_,
            headers: {
                "Content-Type": "application/json",
                "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.processSetChannelsMode(_response);
        });
    }

    protected processSetChannelsMode(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);
    }

    /**
     * 启动触发器，开始信号捕获
     */
    startTrigger( cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/Debugger/StartTrigger";
        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.processStartTrigger(_response);
        });
    }

    protected processStartTrigger(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);
    }

    /**
     * 读取触发器状态标志
     */
    readFlag( cancelToken?: CancelToken): Promise<number> {
        let url_ = this.baseUrl + "/api/Debugger/ReadFlag";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processReadFlag(_response);
        });
    }

    protected processReadFlag(response: AxiosResponse): Promise<number> {
        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<number>(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<number>(null as any);
    }

    /**
     * 清除触发器状态标志
     */
    clearFlag( cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/Debugger/ClearFlag";
        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.processClearFlag(_response);
        });
    }

    protected processClearFlag(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 调试器配置信息，包含采样深度、端口数、通道配置等
     */
    readData(config: DebuggerConfig, cancelToken?: CancelToken): Promise<ChannelCaptureData[]> {
        let url_ = this.baseUrl + "/api/Debugger/ReadData";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(config);

        let options_: AxiosRequestConfig = {
            data: content_,
            method: "POST",
            url: url_,
            headers: {
                "Content-Type": "application/json",
                "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.processReadData(_response);
        });
    }

    protected processReadData(response: AxiosResponse): Promise<ChannelCaptureData[]> {
        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;
            if (Array.isArray(resultData200)) {
                result200 = [] as any;
                for (let item of resultData200)
                    result200!.push(ChannelCaptureData.fromJS(item));
            }
            else {
                result200 = <any>null;
            }
            return Promise.resolve<ChannelCaptureData[]>(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<ChannelCaptureData[]>(null as any);
    }

    /**
     * 刷新调试器状态（重置采集状态等）
     */
    refresh( cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/Debugger/Refresh";
        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.processRefresh(_response);
        });
    }

    protected processRefresh(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);
    }
}

export class ExamClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    /**
     * 获取所有实验列表
     * @return 实验列表
     */
    getExamList( cancelToken?: CancelToken): Promise<ExamInfo[]> {
        let url_ = this.baseUrl + "/api/Exam/list";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetExamList(_response);
        });
    }

    protected processGetExamList(response: AxiosResponse): Promise<ExamInfo[]> {
        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;
            if (Array.isArray(resultData200)) {
                result200 = [] as any;
                for (let item of resultData200)
                    result200!.push(ExamInfo.fromJS(item));
            }
            else {
                result200 = <any>null;
            }
            return Promise.resolve<ExamInfo[]>(result200);

        } 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 === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<ExamInfo[]>(null as any);
    }

    /**
     * 根据实验ID获取实验详细信息
     * @param examId 实验ID
     * @return 实验详细信息
     */
    getExam(examId: string, cancelToken?: CancelToken): Promise<ExamInfo> {
        let url_ = this.baseUrl + "/api/Exam/{examId}";
        if (examId === undefined || examId === null)
            throw new Error("The parameter 'examId' must be defined.");
        url_ = url_.replace("{examId}", encodeURIComponent("" + examId));
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetExam(_response);
        });
    }

    protected processGetExam(response: AxiosResponse): Promise<ExamInfo> {
        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 = ExamInfo.fromJS(resultData200);
            return Promise.resolve<ExamInfo>(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 === 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 === 404) {
            const _responseText = response.data;
            let result404: any = null;
            let resultData404  = _responseText;
            result404 = ProblemDetails.fromJS(resultData404);
            return throwException("A server side error occurred.", status, _responseText, _headers, result404);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<ExamInfo>(null as any);
    }

    /**
     * 创建新实验
     * @param request 创建实验请求
     * @return 创建结果
     */
    createExam(request: ExamDto, cancelToken?: CancelToken): Promise<ExamInfo> {
        let url_ = this.baseUrl + "/api/Exam/create";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(request);

        let options_: AxiosRequestConfig = {
            data: content_,
            method: "POST",
            url: url_,
            headers: {
                "Content-Type": "application/json",
                "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.processCreateExam(_response);
        });
    }

    protected processCreateExam(response: AxiosResponse): Promise<ExamInfo> {
        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 === 201) {
            const _responseText = response.data;
            let result201: any = null;
            let resultData201  = _responseText;
            result201 = ExamInfo.fromJS(resultData201);
            return Promise.resolve<ExamInfo>(result201);

        } 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 === 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 === 403) {
            const _responseText = response.data;
            let result403: any = null;
            let resultData403  = _responseText;
            result403 = ProblemDetails.fromJS(resultData403);
            return throwException("A server side error occurred.", status, _responseText, _headers, result403);

        } else if (status === 409) {
            const _responseText = response.data;
            let result409: any = null;
            let resultData409  = _responseText;
            result409 = ProblemDetails.fromJS(resultData409);
            return throwException("A server side error occurred.", status, _responseText, _headers, result409);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<ExamInfo>(null as any);
    }

    /**
     * 更新实验信息
     * @param request 更新实验请求
     * @return 更新结果
     */
    updateExam(request: ExamDto, cancelToken?: CancelToken): Promise<ExamInfo> {
        let url_ = this.baseUrl + "/api/Exam/update";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(request);

        let options_: AxiosRequestConfig = {
            data: content_,
            method: "POST",
            url: url_,
            headers: {
                "Content-Type": "application/json",
                "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.processUpdateExam(_response);
        });
    }

    protected processUpdateExam(response: AxiosResponse): Promise<ExamInfo> {
        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 = ExamInfo.fromJS(resultData200);
            return Promise.resolve<ExamInfo>(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 === 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 === 403) {
            const _responseText = response.data;
            let result403: any = null;
            let resultData403  = _responseText;
            result403 = ProblemDetails.fromJS(resultData403);
            return throwException("A server side error occurred.", status, _responseText, _headers, result403);

        } else if (status === 404) {
            const _responseText = response.data;
            let result404: any = null;
            let resultData404  = _responseText;
            result404 = ProblemDetails.fromJS(resultData404);
            return throwException("A server side error occurred.", status, _responseText, _headers, result404);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<ExamInfo>(null as any);
    }

    /**
     * 提交作业
     * @param examId 实验ID
     * @param file (optional) 提交的文件
     * @return 提交结果
     */
    submitCommit(examId: string, file: FileParameter | undefined, cancelToken?: CancelToken): Promise<Commit> {
        let url_ = this.baseUrl + "/api/Exam/commit/{examId}";
        if (examId === undefined || examId === null)
            throw new Error("The parameter 'examId' must be defined.");
        url_ = url_.replace("{examId}", encodeURIComponent("" + examId));
        url_ = url_.replace(/[?&]$/, "");

        const content_ = new FormData();
        if (file === null || file === undefined)
            throw new Error("The parameter 'file' cannot be null.");
        else
            content_.append("file", file.data, file.fileName ? file.fileName : "file");

        let options_: AxiosRequestConfig = {
            data: content_,
            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.processSubmitCommit(_response);
        });
    }

    protected processSubmitCommit(response: AxiosResponse): Promise<Commit> {
        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 === 201) {
            const _responseText = response.data;
            let result201: any = null;
            let resultData201  = _responseText;
            result201 = Commit.fromJS(resultData201);
            return Promise.resolve<Commit>(result201);

        } 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 === 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 === 404) {
            const _responseText = response.data;
            let result404: any = null;
            let resultData404  = _responseText;
            result404 = ProblemDetails.fromJS(resultData404);
            return throwException("A server side error occurred.", status, _responseText, _headers, result404);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<Commit>(null as any);
    }

    /**
     * 获取用户在指定实验中的提交记录
     * @param examId 实验ID
     * @return 提交记录列表
     */
    getCommitsByExamId(examId: string, cancelToken?: CancelToken): Promise<Commit[]> {
        let url_ = this.baseUrl + "/api/Exam/commits/{examId}";
        if (examId === undefined || examId === null)
            throw new Error("The parameter 'examId' must be defined.");
        url_ = url_.replace("{examId}", encodeURIComponent("" + examId));
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetCommitsByExamId(_response);
        });
    }

    protected processGetCommitsByExamId(response: AxiosResponse): Promise<Commit[]> {
        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;
            if (Array.isArray(resultData200)) {
                result200 = [] as any;
                for (let item of resultData200)
                    result200!.push(Commit.fromJS(item));
            }
            else {
                result200 = <any>null;
            }
            return Promise.resolve<Commit[]>(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 === 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 === 404) {
            const _responseText = response.data;
            let result404: any = null;
            let resultData404  = _responseText;
            result404 = ProblemDetails.fromJS(resultData404);
            return throwException("A server side error occurred.", status, _responseText, _headers, result404);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<Commit[]>(null as any);
    }

    /**
     * 删除提交记录
     * @param commitId 提交记录ID
     * @return 删除结果
     */
    deleteCommit(commitId: string, cancelToken?: CancelToken): Promise<void> {
        let url_ = this.baseUrl + "/api/Exam/commit/{commitId}";
        if (commitId === undefined || commitId === null)
            throw new Error("The parameter 'commitId' must be defined.");
        url_ = url_.replace("{commitId}", encodeURIComponent("" + commitId));
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "DELETE",
            url: url_,
            headers: {
            },
            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.processDeleteCommit(_response);
        });
    }

    protected processDeleteCommit(response: AxiosResponse): Promise<void> {
        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;
            return Promise.resolve<void>(null as any);

        } 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 === 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 === 403) {
            const _responseText = response.data;
            let result403: any = null;
            let resultData403  = _responseText;
            result403 = ProblemDetails.fromJS(resultData403);
            return throwException("A server side error occurred.", status, _responseText, _headers, result403);

        } else if (status === 404) {
            const _responseText = response.data;
            let result404: any = null;
            let resultData404  = _responseText;
            result404 = ProblemDetails.fromJS(resultData404);
            return throwException("A server side error occurred.", status, _responseText, _headers, result404);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<void>(null as any);
    }
}

export class HdmiVideoStreamClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    getAllEndpoints( cancelToken?: CancelToken): Promise<HdmiVideoStreamEndpoint[]> {
        let url_ = this.baseUrl + "/api/HdmiVideoStream/AllEndpoints";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetAllEndpoints(_response);
        });
    }

    protected processGetAllEndpoints(response: AxiosResponse): Promise<HdmiVideoStreamEndpoint[]> {
        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;
            if (Array.isArray(resultData200)) {
                result200 = [] as any;
                for (let item of resultData200)
                    result200!.push(HdmiVideoStreamEndpoint.fromJS(item));
            }
            else {
                result200 = <any>null;
            }
            return Promise.resolve<HdmiVideoStreamEndpoint[]>(result200);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<HdmiVideoStreamEndpoint[]>(null as any);
    }

    getMyEndpoint( cancelToken?: CancelToken): Promise<HdmiVideoStreamEndpoint> {
        let url_ = this.baseUrl + "/api/HdmiVideoStream/MyEndpoint";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetMyEndpoint(_response);
        });
    }

    protected processGetMyEndpoint(response: AxiosResponse): Promise<HdmiVideoStreamEndpoint> {
        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 = HdmiVideoStreamEndpoint.fromJS(resultData200);
            return Promise.resolve<HdmiVideoStreamEndpoint>(result200);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<HdmiVideoStreamEndpoint>(null as any);
    }

    disableHdmiTransmission( cancelToken?: CancelToken): Promise<FileResponse | null> {
        let url_ = this.baseUrl + "/api/HdmiVideoStream/DisableHdmiTransmission";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            responseType: "blob",
            method: "POST",
            url: url_,
            headers: {
                "Accept": "application/octet-stream"
            },
            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.processDisableHdmiTransmission(_response);
        });
    }

    protected processDisableHdmiTransmission(response: AxiosResponse): Promise<FileResponse | null> {
        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 || status === 206) {
            const contentDisposition = response.headers ? response.headers["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 Promise.resolve({ fileName: fileName, status: status, data: new Blob([response.data], { type: response.headers["content-type"] }), headers: _headers });
        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<FileResponse | null>(null as any);
    }
}

export class JtagClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    /**
     * 控制器首页信息
     * @return 控制器描述信息
     */
    index( cancelToken?: CancelToken): Promise<string> {
        let url_ = this.baseUrl + "/api/Jtag";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processIndex(_response);
        });
    }

    protected processIndex(response: AxiosResponse): Promise<string> {
        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<string>(result200);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<string>(null as any);
    }

    /**
     * 获取 JTAG 设备的 ID Code
     * @param address (optional) JTAG 设备地址
     * @param port (optional) JTAG 设备端口
     * @return 设备的 ID Code
     */
    getDeviceIDCode(address: string | undefined, port: number | undefined, cancelToken?: CancelToken): Promise<number> {
        let url_ = this.baseUrl + "/api/Jtag/GetDeviceIDCode?";
        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_: AxiosRequestConfig = {
            method: "GET",
            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.processGetDeviceIDCode(_response);
        });
    }

    protected processGetDeviceIDCode(response: AxiosResponse): Promise<number> {
        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<number>(result200);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } 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<number>(null as any);
    }

    /**
     * 读取 JTAG 设备的状态寄存器
     * @param address (optional) JTAG 设备地址
     * @param port (optional) JTAG 设备端口
     * @return 状态寄存器的原始值、二进制表示和解码值
     */
    readStatusReg(address: string | undefined, port: number | undefined, cancelToken?: CancelToken): Promise<void> {
        let url_ = this.baseUrl + "/api/Jtag/ReadStatusReg?";
        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_: AxiosRequestConfig = {
            method: "GET",
            url: url_,
            headers: {
            },
            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.processReadStatusReg(_response);
        });
    }

    protected processReadStatusReg(response: AxiosResponse): Promise<void> {
        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;
            return Promise.resolve<void>(null as any);

        } 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<void>(null as any);
    }

    /**
     * 通过 JTAG 下载比特流文件到 FPGA 设备
     * @param address (optional) JTAG 设备地址
     * @param port (optional) JTAG 设备端口
     * @param bitstreamId (optional) 比特流ID
     * @return 进度跟踪TaskID
     */
    downloadBitstream(address: string | undefined, port: number | undefined, bitstreamId: string | undefined, cancelToken?: CancelToken): Promise<string> {
        let url_ = this.baseUrl + "/api/Jtag/DownloadBitstream?";
        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) + "&";
        if (bitstreamId === null)
            throw new Error("The parameter 'bitstreamId' cannot be null.");
        else if (bitstreamId !== undefined)
            url_ += "bitstreamId=" + encodeURIComponent("" + bitstreamId) + "&";
        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.processDownloadBitstream(_response);
        });
    }

    protected processDownloadBitstream(response: AxiosResponse): Promise<string> {
        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<string>(result200);

        } else if (status === 400) {
            const _responseText = response.data;
            let result400: any = null;
            let resultData400  = _responseText;
                result400 = resultData400 !== undefined ? resultData400 : <any>null;
    
            return throwException("A server side error occurred.", status, _responseText, _headers, result400);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } 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<string>(null as any);
    }

    /**
     * 执行边界扫描，获取所有端口状态
     * @param address (optional) JTAG 设备地址
     * @param port (optional) JTAG 设备端口
     * @return 边界扫描结果
     */
    boundaryScanAllPorts(address: string | undefined, port: number | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/Jtag/BoundaryScanAllPorts?";
        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_: 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.processBoundaryScanAllPorts(_response);
        });
    }

    protected processBoundaryScanAllPorts(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 = resultData400 !== undefined ? resultData400 : <any>null;
    
            return throwException("A server side error occurred.", status, _responseText, _headers, result400);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } 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 address (optional) JTAG 设备地址
     * @param port (optional) JTAG 设备端口
     * @return 逻辑端口状态字典
     */
    boundaryScanLogicalPorts(address: string | undefined, port: number | undefined, cancelToken?: CancelToken): Promise<{ [key: string]: 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_: 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.processBoundaryScanLogicalPorts(_response);
        });
    }

    protected processBoundaryScanLogicalPorts(response: AxiosResponse): Promise<{ [key: string]: 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;
            if (resultData200) {
                result200 = {} as any;
                for (let key in resultData200) {
                    if (resultData200.hasOwnProperty(key))
                        (<any>result200)![key] = resultData200[key] !== undefined ? resultData200[key] : <any>null;
                }
            }
            else {
                result200 = <any>null;
            }
            return Promise.resolve<{ [key: string]: boolean; }>(result200);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } 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<{ [key: string]: boolean; }>(null as any);
    }

    /**
     * 设置 JTAG 时钟速度
     * @param address (optional) JTAG 设备地址
     * @param port (optional) JTAG 设备端口
     * @param speed (optional) 时钟速度 (Hz)
     * @return 设置结果
     */
    setSpeed(address: string | undefined, port: number | undefined, speed: number | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/Jtag/SetSpeed?";
        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) + "&";
        if (speed === null)
            throw new Error("The parameter 'speed' cannot be null.");
        else if (speed !== undefined)
            url_ += "speed=" + encodeURIComponent("" + speed) + "&";
        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.processSetSpeed(_response);
        });
    }

    protected processSetSpeed(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 === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } 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);
    }
}

export class LogicAnalyzerClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    /**
     * 设置捕获模式
     * @param captureOn (optional) 是否开始捕获
     * @param force (optional) 是否强制捕获
     * @return 操作结果
     */
    setCaptureMode(captureOn: boolean | undefined, force: boolean | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/LogicAnalyzer/SetCaptureMode?";
        if (captureOn === null)
            throw new Error("The parameter 'captureOn' cannot be null.");
        else if (captureOn !== undefined)
            url_ += "captureOn=" + encodeURIComponent("" + captureOn) + "&";
        if (force === null)
            throw new Error("The parameter 'force' cannot be null.");
        else if (force !== undefined)
            url_ += "force=" + encodeURIComponent("" + force) + "&";
        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.processSetCaptureMode(_response);
        });
    }

    protected processSetCaptureMode(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);
    }

    /**
     * 读取捕获状态
     * @return 捕获状态
     */
    getCaptureStatus( cancelToken?: CancelToken): Promise<CaptureStatus> {
        let url_ = this.baseUrl + "/api/LogicAnalyzer/GetCaptureStatus";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetCaptureStatus(_response);
        });
    }

    protected processGetCaptureStatus(response: AxiosResponse): Promise<CaptureStatus> {
        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<CaptureStatus>(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<CaptureStatus>(null as any);
    }

    /**
     * 设置全局触发模式
     * @param mode (optional) 全局触发模式
     * @return 操作结果
     */
    setGlobalTrigMode(mode: GlobalCaptureMode | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/LogicAnalyzer/SetGlobalTrigMode?";
        if (mode === null)
            throw new Error("The parameter 'mode' cannot be null.");
        else if (mode !== undefined)
            url_ += "mode=" + encodeURIComponent("" + mode) + "&";
        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.processSetGlobalTrigMode(_response);
        });
    }

    protected processSetGlobalTrigMode(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 signalIndex (optional) 信号索引 (0-7)
     * @param op (optional) 操作符
     * @param val (optional) 信号值
     * @return 操作结果
     */
    setSignalTrigMode(signalIndex: number | undefined, op: SignalOperator | undefined, val: SignalValue | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/LogicAnalyzer/SetSignalTrigMode?";
        if (signalIndex === null)
            throw new Error("The parameter 'signalIndex' cannot be null.");
        else if (signalIndex !== undefined)
            url_ += "signalIndex=" + encodeURIComponent("" + signalIndex) + "&";
        if (op === null)
            throw new Error("The parameter 'op' cannot be null.");
        else if (op !== undefined)
            url_ += "op=" + encodeURIComponent("" + op) + "&";
        if (val === null)
            throw new Error("The parameter 'val' cannot be null.");
        else if (val !== undefined)
            url_ += "val=" + encodeURIComponent("" + val) + "&";
        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.processSetSignalTrigMode(_response);
        });
    }

    protected processSetSignalTrigMode(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 capture_length (optional) 深度
     * @param pre_capture_length (optional) 预采样深度
     * @param channel_div (optional) 有效通道(0-[1],1-[2],2-[4],3-[8],4-[16],5-[32])
     * @param clock_div (optional) 采样时钟分频系数
     * @return 操作结果
     */
    setCaptureParams(capture_length: number | undefined, pre_capture_length: number | undefined, channel_div: AnalyzerChannelDiv | undefined, clock_div: AnalyzerClockDiv | 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) + "&";
        if (clock_div === null)
            throw new Error("The parameter 'clock_div' cannot be null.");
        else if (clock_div !== undefined)
            url_ += "clock_div=" + encodeURIComponent("" + clock_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 捕获配置
     * @return 操作结果
     */
    configureCapture(config: CaptureConfig, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/LogicAnalyzer/ConfigureCapture";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(config);

        let options_: AxiosRequestConfig = {
            data: content_,
            method: "POST",
            url: url_,
            headers: {
                "Content-Type": "application/json",
                "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.processConfigureCapture(_response);
        });
    }

    protected processConfigureCapture(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);
    }

    /**
     * 强制捕获
     * @return 操作结果
     */
    forceCapture( cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/LogicAnalyzer/ForceCapture";
        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.processForceCapture(_response);
        });
    }

    protected processForceCapture(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 capture_length (optional) 
     * @return 捕获的波形数据（Base64编码）
     */
    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 = {
            method: "GET",
            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.processGetCaptureData(_response);
        });
    }

    protected processGetCaptureData(response: AxiosResponse): Promise<string> {
        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<string>(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<string>(null as any);
    }
}

export class MatrixKeyClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    /**
     * 启用矩阵键控制。
     * @param address (optional) 设备的IP地址
     * @param port (optional) 设备的端口号
     * @return 返回操作结果的状态码
     */
    enabelMatrixKey(address: string | undefined, port: number | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/MatrixKey/EnabelMatrixKey?";
        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_: 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.processEnabelMatrixKey(_response);
        });
    }

    protected processEnabelMatrixKey(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 === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } 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 address (optional) 设备的IP地址
     * @param port (optional) 设备的端口号
     * @return 返回操作结果的状态码
     */
    disableMatrixKey(address: string | undefined, port: number | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/MatrixKey/DisableMatrixKey?";
        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_: 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.processDisableMatrixKey(_response);
        });
    }

    protected processDisableMatrixKey(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 === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } 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 address (optional) 设备的IP地址
     * @param port (optional) 设备的端口号
     * @param keyStates 矩阵键的状态数组，长度应为16
     * @return 返回操作结果的状态码
     */
    setMatrixKeyStatus(address: string | undefined, port: number | undefined, keyStates: boolean[], cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/MatrixKey/SetMatrixKeyStatus?";
        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(/[?&]$/, "");

        const content_ = JSON.stringify(keyStates);

        let options_: AxiosRequestConfig = {
            data: content_,
            method: "POST",
            url: url_,
            headers: {
                "Content-Type": "application/json",
                "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.processSetMatrixKeyStatus(_response);
        });
    }

    protected processSetMatrixKeyStatus(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 === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } 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);
    }
}

export class NetConfigClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    /**
     * 获取主机IP地址
     * @return 主机IP地址
     */
    getHostIP( cancelToken?: CancelToken): Promise<string> {
        let url_ = this.baseUrl + "/api/NetConfig/GetHostIP";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetHostIP(_response);
        });
    }

    protected processGetHostIP(response: AxiosResponse): Promise<string> {
        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<string>(result200);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<string>(null as any);
    }

    /**
     * 获取板卡IP地址
     * @return 板卡IP地址
     */
    getBoardIP( cancelToken?: CancelToken): Promise<string> {
        let url_ = this.baseUrl + "/api/NetConfig/GetBoardIP";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetBoardIP(_response);
        });
    }

    protected processGetBoardIP(response: AxiosResponse): Promise<string> {
        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<string>(result200);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<string>(null as any);
    }

    /**
     * 获取主机MAC地址
     * @return 主机MAC地址
     */
    getHostMAC( cancelToken?: CancelToken): Promise<string> {
        let url_ = this.baseUrl + "/api/NetConfig/GetHostMAC";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetHostMAC(_response);
        });
    }

    protected processGetHostMAC(response: AxiosResponse): Promise<string> {
        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<string>(result200);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<string>(null as any);
    }

    /**
     * 获取板卡MAC地址
     * @return 板卡MAC地址
     */
    getBoardMAC( cancelToken?: CancelToken): Promise<string> {
        let url_ = this.baseUrl + "/api/NetConfig/GetBoardMAC";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetBoardMAC(_response);
        });
    }

    protected processGetBoardMAC(response: AxiosResponse): Promise<string> {
        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<string>(result200);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<string>(null as any);
    }

    /**
     * 获取所有网络配置信息
     * @return 网络配置信息
     */
    getNetworkConfig( cancelToken?: CancelToken): Promise<NetworkConfigDto> {
        let url_ = this.baseUrl + "/api/NetConfig/GetNetworkConfig";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetNetworkConfig(_response);
        });
    }

    protected processGetNetworkConfig(response: AxiosResponse): Promise<NetworkConfigDto> {
        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 = NetworkConfigDto.fromJS(resultData200);
            return Promise.resolve<NetworkConfigDto>(result200);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<NetworkConfigDto>(null as any);
    }

    /**
     * 获取本机所有网络接口信息
     * @return 网络接口信息列表
     */
    getLocalNetworkInterfaces( cancelToken?: CancelToken): Promise<NetworkInterfaceDto[]> {
        let url_ = this.baseUrl + "/api/NetConfig/GetLocalNetworkInterfaces";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetLocalNetworkInterfaces(_response);
        });
    }

    protected processGetLocalNetworkInterfaces(response: AxiosResponse): Promise<NetworkInterfaceDto[]> {
        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;
            if (Array.isArray(resultData200)) {
                result200 = [] as any;
                for (let item of resultData200)
                    result200!.push(NetworkInterfaceDto.fromJS(item));
            }
            else {
                result200 = <any>null;
            }
            return Promise.resolve<NetworkInterfaceDto[]>(result200);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<NetworkInterfaceDto[]>(null as any);
    }

    /**
     * 设置主机IP地址
     * @param hostIp (optional) 主机IP地址
     * @return 操作结果
     */
    setHostIP(hostIp: string | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/NetConfig/SetHostIP?";
        if (hostIp === null)
            throw new Error("The parameter 'hostIp' cannot be null.");
        else if (hostIp !== undefined)
            url_ += "hostIp=" + encodeURIComponent("" + hostIp) + "&";
        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.processSetHostIP(_response);
        });
    }

    protected processSetHostIP(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 !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<boolean>(null as any);
    }

    /**
     * 设置板卡IP地址
     * @param newBoardIp (optional) 新的板卡IP地址
     * @return 操作结果
     */
    setBoardIP(newBoardIp: string | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/NetConfig/SetBoardIP?";
        if (newBoardIp === null)
            throw new Error("The parameter 'newBoardIp' cannot be null.");
        else if (newBoardIp !== undefined)
            url_ += "newBoardIp=" + encodeURIComponent("" + newBoardIp) + "&";
        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.processSetBoardIP(_response);
        });
    }

    protected processSetBoardIP(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 !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<boolean>(null as any);
    }

    /**
     * 设置板卡MAC地址
     * @param boardMac (optional) 板卡MAC地址（格式：AA:BB:CC:DD:EE:FF）
     * @return 操作结果
     */
    setBoardMAC(boardMac: string | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/NetConfig/SetBoardMAC?";
        if (boardMac === null)
            throw new Error("The parameter 'boardMac' cannot be null.");
        else if (boardMac !== undefined)
            url_ += "boardMac=" + encodeURIComponent("" + boardMac) + "&";
        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.processSetBoardMAC(_response);
        });
    }

    protected processSetBoardMAC(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 !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<boolean>(null as any);
    }

    /**
     * 设置主机MAC地址
     * @param hostMac (optional) 主机MAC地址（格式：AA:BB:CC:DD:EE:FF）
     * @return 操作结果
     */
    setHostMAC(hostMac: string | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/NetConfig/SetHostMAC?";
        if (hostMac === null)
            throw new Error("The parameter 'hostMac' cannot be null.");
        else if (hostMac !== undefined)
            url_ += "hostMac=" + encodeURIComponent("" + hostMac) + "&";
        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.processSetHostMAC(_response);
        });
    }

    protected processSetHostMAC(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 !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<boolean>(null as any);
    }

    /**
     * 自动获取本机IP地址并设置为实验板主机IP
     * @return 操作结果
     */
    updateHostIP( cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/NetConfig/UpdateHostIP";
        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.processUpdateHostIP(_response);
        });
    }

    protected processUpdateHostIP(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 === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } 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);
    }

    /**
     * 更新主机MAC地址
     * @return 操作结果
     */
    updateHostMAC( cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/NetConfig/UpdateHostMAC";
        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.processUpdateHostMAC(_response);
        });
    }

    protected processUpdateHostMAC(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 !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<boolean>(null as any);
    }

    /**
     * 获取本机网络信息
     * @return 本机网络信息
     */
    getLocalNetworkInfo( cancelToken?: CancelToken): Promise<any> {
        let url_ = this.baseUrl + "/api/NetConfig/GetLocalNetworkInfo";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetLocalNetworkInfo(_response);
        });
    }

    protected processGetLocalNetworkInfo(response: AxiosResponse): Promise<any> {
        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<any>(result200);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<any>(null as any);
    }
}

export class OscilloscopeApiClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    /**
     * 初始化示波器
     * @param config 示波器配置
     * @return 操作结果
     */
    initialize(config: OscilloscopeFullConfig, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/OscilloscopeApi/Initialize";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(config);

        let options_: AxiosRequestConfig = {
            data: content_,
            method: "POST",
            url: url_,
            headers: {
                "Content-Type": "application/json",
                "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.processInitialize(_response);
        });
    }

    protected processInitialize(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);
    }

    /**
     * 启动捕获
     * @return 操作结果
     */
    startCapture( cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/OscilloscopeApi/StartCapture";
        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.processStartCapture(_response);
        });
    }

    protected processStartCapture(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);
    }

    /**
     * 停止捕获
     * @return 操作结果
     */
    stopCapture( cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/OscilloscopeApi/StopCapture";
        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.processStopCapture(_response);
        });
    }

    protected processStopCapture(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);
    }

    /**
     * 获取示波器数据和状态
     * @return 示波器数据和状态信息
     */
    getData( cancelToken?: CancelToken): Promise<OscilloscopeDataResponse> {
        let url_ = this.baseUrl + "/api/OscilloscopeApi/GetData";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetData(_response);
        });
    }

    protected processGetData(response: AxiosResponse): Promise<OscilloscopeDataResponse> {
        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 = OscilloscopeDataResponse.fromJS(resultData200);
            return Promise.resolve<OscilloscopeDataResponse>(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<OscilloscopeDataResponse>(null as any);
    }

    /**
     * 更新触发参数
     * @param level (optional) 触发电平（0-255）
     * @param risingEdge (optional) 触发边沿（true为上升沿，false为下降沿）
     * @return 操作结果
     */
    updateTrigger(level: number | undefined, risingEdge: boolean | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/OscilloscopeApi/UpdateTrigger?";
        if (level === null)
            throw new Error("The parameter 'level' cannot be null.");
        else if (level !== undefined)
            url_ += "level=" + encodeURIComponent("" + level) + "&";
        if (risingEdge === null)
            throw new Error("The parameter 'risingEdge' cannot be null.");
        else if (risingEdge !== undefined)
            url_ += "risingEdge=" + encodeURIComponent("" + risingEdge) + "&";
        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.processUpdateTrigger(_response);
        });
    }

    protected processUpdateTrigger(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 horizontalShift (optional) 水平偏移量（0-1023）
     * @param decimationRate (optional) 抽样率（0-1023）
     * @return 操作结果
     */
    updateSampling(horizontalShift: number | undefined, decimationRate: number | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/OscilloscopeApi/UpdateSampling?";
        if (horizontalShift === null)
            throw new Error("The parameter 'horizontalShift' cannot be null.");
        else if (horizontalShift !== undefined)
            url_ += "horizontalShift=" + encodeURIComponent("" + horizontalShift) + "&";
        if (decimationRate === null)
            throw new Error("The parameter 'decimationRate' cannot be null.");
        else if (decimationRate !== undefined)
            url_ += "decimationRate=" + encodeURIComponent("" + decimationRate) + "&";
        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.processUpdateSampling(_response);
        });
    }

    protected processUpdateSampling(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);
    }

    /**
     * 手动刷新RAM
     * @return 操作结果
     */
    refreshRAM( cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/OscilloscopeApi/RefreshRAM";
        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.processRefreshRAM(_response);
        });
    }

    protected processRefreshRAM(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);
    }
}

export class PowerClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    /**
     * [TODO:description]
     * @param address (optional) [TODO:parameter]
     * @param port (optional) [TODO:parameter]
     * @param enable (optional) [TODO:parameter]
     * @return [TODO:return]
     */
    setPowerOnOff(address: string | undefined, port: number | undefined, enable: boolean | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/Power/SetPowerOnOff?";
        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) + "&";
        if (enable === null)
            throw new Error("The parameter 'enable' cannot be null.");
        else if (enable !== undefined)
            url_ += "enable=" + encodeURIComponent("" + enable) + "&";
        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.processSetPowerOnOff(_response);
        });
    }

    protected processSetPowerOnOff(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 === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } 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);
    }
}

export class RemoteUpdateClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    /**
     * 上传远程更新比特流文件
     * @param address (optional) 设备地址
     * @param goldenBitream (optional) 黄金比特流文件
     * @param bitstream1 (optional) 比特流文件1
     * @param bitstream2 (optional) 比特流文件2
     * @param bitstream3 (optional) 比特流文件3
     * @return 上传结果
     */
    uploadBitstreams(address: string | undefined, goldenBitream: FileParameter | null | undefined, bitstream1: FileParameter | null | undefined, bitstream2: FileParameter | null | undefined, bitstream3: FileParameter | null | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/RemoteUpdate/UploadBitstream?";
        if (address === null)
            throw new Error("The parameter 'address' cannot be null.");
        else if (address !== undefined)
            url_ += "address=" + encodeURIComponent("" + address) + "&";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = new FormData();
        if (goldenBitream !== null && goldenBitream !== undefined)
            content_.append("goldenBitream", goldenBitream.data, goldenBitream.fileName ? goldenBitream.fileName : "goldenBitream");
        if (bitstream1 !== null && bitstream1 !== undefined)
            content_.append("bitstream1", bitstream1.data, bitstream1.fileName ? bitstream1.fileName : "bitstream1");
        if (bitstream2 !== null && bitstream2 !== undefined)
            content_.append("bitstream2", bitstream2.data, bitstream2.fileName ? bitstream2.fileName : "bitstream2");
        if (bitstream3 !== null && bitstream3 !== undefined)
            content_.append("bitstream3", bitstream3.data, bitstream3.fileName ? bitstream3.fileName : "bitstream3");

        let options_: AxiosRequestConfig = {
            data: content_,
            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.processUploadBitstreams(_response);
        });
    }

    protected processUploadBitstreams(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 = ArgumentException.fromJS(resultData400);
            return throwException("A server side error occurred.", status, _responseText, _headers, result400);

        } 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 address (optional) 设备地址
     * @param port (optional) 设备端口
     * @param bitstreamNum (optional) 比特流位号
     */
    updateBitstream(address: string | undefined, port: number | undefined, bitstreamNum: number | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/RemoteUpdate/DownloadBitstream?";
        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) + "&";
        if (bitstreamNum === null)
            throw new Error("The parameter 'bitstreamNum' cannot be null.");
        else if (bitstreamNum !== undefined)
            url_ += "bitstreamNum=" + encodeURIComponent("" + bitstreamNum) + "&";
        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.processUpdateBitstream(_response);
        });
    }

    protected processUpdateBitstream(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 = ArgumentException.fromJS(resultData400);
            return throwException("A server side error occurred.", status, _responseText, _headers, result400);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } 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 address (optional) 设备地址
     * @param port (optional) 设备端口
     * @param bitstreamNum (optional) 比特流编号
     * @return 总共上传比特流的数量
     */
    downloadMultiBitstreams(address: string | undefined, port: number | undefined, bitstreamNum: number | null | undefined, cancelToken?: CancelToken): Promise<number> {
        let url_ = this.baseUrl + "/api/RemoteUpdate/DownloadMultiBitstreams?";
        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) + "&";
        if (bitstreamNum !== undefined && bitstreamNum !== null)
            url_ += "bitstreamNum=" + encodeURIComponent("" + bitstreamNum) + "&";
        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.processDownloadMultiBitstreams(_response);
        });
    }

    protected processDownloadMultiBitstreams(response: AxiosResponse): Promise<number> {
        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<number>(result200);

        } else if (status === 400) {
            const _responseText = response.data;
            let result400: any = null;
            let resultData400  = _responseText;
            result400 = ArgumentException.fromJS(resultData400);
            return throwException("A server side error occurred.", status, _responseText, _headers, result400);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<number>(null as any);
    }

    /**
     * 热复位比特流文件
     * @param address (optional) 设备地址
     * @param port (optional) 设备端口
     * @param bitstreamNum (optional) 比特流编号
     * @return 操作结果
     */
    hotResetBitstream(address: string | undefined, port: number | undefined, bitstreamNum: number | undefined, cancelToken?: CancelToken): Promise<boolean> {
        let url_ = this.baseUrl + "/api/RemoteUpdate/HotResetBitstream?";
        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) + "&";
        if (bitstreamNum === null)
            throw new Error("The parameter 'bitstreamNum' cannot be null.");
        else if (bitstreamNum !== undefined)
            url_ += "bitstreamNum=" + encodeURIComponent("" + bitstreamNum) + "&";
        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.processHotResetBitstream(_response);
        });
    }

    protected processHotResetBitstream(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 = ArgumentException.fromJS(resultData400);
            return throwException("A server side error occurred.", status, _responseText, _headers, result400);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } 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);
    }

    /**
     * [TODO:description]
     * @param address (optional) [TODO:parameter]
     * @param port (optional) [TODO:parameter]
     * @return [TODO:return]
     */
    getFirmwareVersion(address: string | undefined, port: number | undefined, cancelToken?: CancelToken): Promise<number> {
        let url_ = this.baseUrl + "/api/RemoteUpdate/GetFirmwareVersion?";
        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_: 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.processGetFirmwareVersion(_response);
        });
    }

    protected processGetFirmwareVersion(response: AxiosResponse): Promise<number> {
        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<number>(result200);

        } else if (status === 400) {
            const _responseText = response.data;
            let result400: any = null;
            let resultData400  = _responseText;
            result400 = ArgumentException.fromJS(resultData400);
            return throwException("A server side error occurred.", status, _responseText, _headers, result400);

        } else if (status === 500) {
            const _responseText = response.data;
            let result500: any = null;
            let resultData500  = _responseText;
            result500 = Exception.fromJS(resultData500);
            return throwException("A server side error occurred.", status, _responseText, _headers, result500);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<number>(null as any);
    }
}

export class ResourceClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    /**
     * 添加资源（文件上传）
     * @param resourceType (optional) 资源类型
     * @param resourcePurpose (optional) 资源用途（template/user）
     * @param examID (optional) 所属实验ID（可选）
     * @param file (optional) 资源文件
     * @return 添加结果
     */
    addResource(resourceType: string | undefined, resourcePurpose: string | undefined, examID: string | null | undefined, file: FileParameter | undefined, cancelToken?: CancelToken): Promise<ResourceInfo> {
        let url_ = this.baseUrl + "/api/Resource";
        url_ = url_.replace(/[?&]$/, "");

        const content_ = new FormData();
        if (resourceType === null || resourceType === undefined)
            throw new Error("The parameter 'resourceType' cannot be null.");
        else
            content_.append("ResourceType", resourceType.toString());
        if (resourcePurpose === null || resourcePurpose === undefined)
            throw new Error("The parameter 'resourcePurpose' cannot be null.");
        else
            content_.append("ResourcePurpose", resourcePurpose.toString());
        if (examID !== null && examID !== undefined)
            content_.append("ExamID", examID.toString());
        if (file === null || file === undefined)
            throw new Error("The parameter 'file' cannot be null.");
        else
            content_.append("file", file.data, file.fileName ? file.fileName : "file");

        let options_: AxiosRequestConfig = {
            data: content_,
            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.processAddResource(_response);
        });
    }

    protected processAddResource(response: AxiosResponse): Promise<ResourceInfo> {
        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 === 201) {
            const _responseText = response.data;
            let result201: any = null;
            let resultData201  = _responseText;
            result201 = ResourceInfo.fromJS(resultData201);
            return Promise.resolve<ResourceInfo>(result201);

        } 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 === 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 === 404) {
            const _responseText = response.data;
            let result404: any = null;
            let resultData404  = _responseText;
            result404 = ProblemDetails.fromJS(resultData404);
            return throwException("A server side error occurred.", status, _responseText, _headers, result404);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<ResourceInfo>(null as any);
    }

    /**
     * 获取资源列表
     * @param examId (optional) 实验ID（可选）
     * @param resourceType (optional) 资源类型（可选）
     * @param resourcePurpose (optional) 资源用途（可选）
     * @return 资源列表
     */
    getResourceList(examId: string | null | undefined, resourceType: string | null | undefined, resourcePurpose: string | null | undefined, cancelToken?: CancelToken): Promise<ResourceInfo[]> {
        let url_ = this.baseUrl + "/api/Resource?";
        if (examId !== undefined && examId !== null)
            url_ += "examId=" + encodeURIComponent("" + examId) + "&";
        if (resourceType !== undefined && resourceType !== null)
            url_ += "resourceType=" + encodeURIComponent("" + resourceType) + "&";
        if (resourcePurpose !== undefined && resourcePurpose !== null)
            url_ += "resourcePurpose=" + encodeURIComponent("" + resourcePurpose) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetResourceList(_response);
        });
    }

    protected processGetResourceList(response: AxiosResponse): Promise<ResourceInfo[]> {
        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;
            if (Array.isArray(resultData200)) {
                result200 = [] as any;
                for (let item of resultData200)
                    result200!.push(ResourceInfo.fromJS(item));
            }
            else {
                result200 = <any>null;
            }
            return Promise.resolve<ResourceInfo[]>(result200);

        } 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 === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<ResourceInfo[]>(null as any);
    }

    /**
     * 根据资源ID下载资源
     * @param resourceId 资源ID
     * @return 资源文件
     */
    getResourceById(resourceId: string, cancelToken?: CancelToken): Promise<FileResponse> {
        let url_ = this.baseUrl + "/api/Resource/{resourceId}";
        if (resourceId === undefined || resourceId === null)
            throw new Error("The parameter 'resourceId' must be defined.");
        url_ = url_.replace("{resourceId}", encodeURIComponent("" + resourceId));
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            responseType: "blob",
            method: "GET",
            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.processGetResourceById(_response);
        });
    }

    protected processGetResourceById(response: AxiosResponse): Promise<FileResponse> {
        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 || status === 206) {
            const contentDisposition = response.headers ? response.headers["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 Promise.resolve({ fileName: fileName, status: status, data: new Blob([response.data], { type: response.headers["content-type"] }), headers: _headers });
        } 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 === 404) {
            const _responseText = response.data;
            let result404: any = null;
            let resultData404  = _responseText;
            result404 = ProblemDetails.fromJS(resultData404);
            return throwException("A server side error occurred.", status, _responseText, _headers, result404);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<FileResponse>(null as any);
    }

    /**
     * 删除资源
     * @param resourceId 资源ID
     * @return 删除结果
     */
    deleteResource(resourceId: string, cancelToken?: CancelToken): Promise<void> {
        let url_ = this.baseUrl + "/api/Resource/{resourceId}";
        if (resourceId === undefined || resourceId === null)
            throw new Error("The parameter 'resourceId' must be defined.");
        url_ = url_.replace("{resourceId}", encodeURIComponent("" + resourceId));
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "DELETE",
            url: url_,
            headers: {
            },
            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.processDeleteResource(_response);
        });
    }

    protected processDeleteResource(response: AxiosResponse): Promise<void> {
        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 === 204) {
            const _responseText = response.data;
            return Promise.resolve<void>(null as any);

        } 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 === 403) {
            const _responseText = response.data;
            let result403: any = null;
            let resultData403  = _responseText;
            result403 = ProblemDetails.fromJS(resultData403);
            return throwException("A server side error occurred.", status, _responseText, _headers, result403);

        } else if (status === 404) {
            const _responseText = response.data;
            let result404: any = null;
            let resultData404  = _responseText;
            result404 = ProblemDetails.fromJS(resultData404);
            return throwException("A server side error occurred.", status, _responseText, _headers, result404);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<void>(null as any);
    }
}

export class TutorialClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    /**
     * 获取所有可用的教程目录
     * @return 教程目录列表
     */
    getTutorials( cancelToken?: CancelToken): Promise<void> {
        let url_ = this.baseUrl + "/api/Tutorial";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            url: url_,
            headers: {
            },
            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.processGetTutorials(_response);
        });
    }

    protected processGetTutorials(response: AxiosResponse): Promise<void> {
        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;
            return Promise.resolve<void>(null as any);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<void>(null as any);
    }
}

export class UDPClient {
    protected instance: AxiosInstance;
    protected baseUrl: string;
    protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;

    constructor(baseUrl?: string, instance?: AxiosInstance) {

        this.instance = instance || axios.create();

        this.baseUrl = baseUrl ?? "http://127.0.0.1:5000";

    }

    /**
     * 页面
     */
    index( cancelToken?: CancelToken): Promise<string> {
        let url_ = this.baseUrl + "/api/UDP";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processIndex(_response);
        });
    }

    protected processIndex(response: AxiosResponse): Promise<string> {
        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<string>(result200);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<string>(null as any);
    }

    /**
     * 发送字符串
     * @param address (optional) IPV4 或者 IPV6 地址
     * @param port (optional) 设备端口号
     * @param text (optional) 发送的文本
     * @return 发送成功
     */
    sendString(address: string | undefined, port: number | undefined, text: string | undefined, cancelToken?: CancelToken): Promise<void> {
        let url_ = this.baseUrl + "/api/UDP/SendString?";
        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) + "&";
        if (text === null)
            throw new Error("The parameter 'text' cannot be null.");
        else if (text !== undefined)
            url_ += "text=" + encodeURIComponent("" + text) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "POST",
            url: url_,
            headers: {
            },
            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.processSendString(_response);
        });
    }

    protected processSendString(response: AxiosResponse): Promise<void> {
        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;
            return Promise.resolve<void>(null as any);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("\u53d1\u9001\u5931\u8d25", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<void>(null as any);
    }

    /**
     * 发送二进制数据
     * @param address (optional) IPV4 或者 IPV6 地址
     * @param port (optional) 设备端口号
     * @param bytes (optional) 16进制文本
     */
    sendBytes(address: string | undefined, port: number | undefined, bytes: string | undefined, cancelToken?: CancelToken): Promise<void> {
        let url_ = this.baseUrl + "/api/UDP/SendBytes?";
        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) + "&";
        if (bytes === null)
            throw new Error("The parameter 'bytes' cannot be null.");
        else if (bytes !== undefined)
            url_ += "bytes=" + encodeURIComponent("" + bytes) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "POST",
            url: url_,
            headers: {
            },
            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.processSendBytes(_response);
        });
    }

    protected processSendBytes(response: AxiosResponse): Promise<void> {
        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;
            return Promise.resolve<void>(null as any);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<void>(null as any);
    }

    /**
     * 发送地址包
     * @param address (optional) IP地址
     * @param port (optional) UDP 端口号
     * @param opts 地址包选项
     */
    sendAddrPackage(address: string | undefined, port: number | undefined, opts: SendAddrPackOptions, cancelToken?: CancelToken): Promise<void> {
        let url_ = this.baseUrl + "/api/UDP/SendAddrPackage?";
        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(/[?&]$/, "");

        const content_ = JSON.stringify(opts);

        let options_: AxiosRequestConfig = {
            data: content_,
            method: "POST",
            url: url_,
            headers: {
                "Content-Type": "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.processSendAddrPackage(_response);
        });
    }

    protected processSendAddrPackage(response: AxiosResponse): Promise<void> {
        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;
            return Promise.resolve<void>(null as any);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<void>(null as any);
    }

    /**
     * 发送数据包
     * @param address (optional) IP地址
     * @param port (optional) UDP 端口号
     * @param data (optional) 16进制数据
     */
    sendDataPackage(address: string | undefined, port: number | undefined, data: string | undefined, cancelToken?: CancelToken): Promise<void> {
        let url_ = this.baseUrl + "/api/UDP/SendDataPackage?";
        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) + "&";
        if (data === null)
            throw new Error("The parameter 'data' cannot be null.");
        else if (data !== undefined)
            url_ += "data=" + encodeURIComponent("" + data) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "POST",
            url: url_,
            headers: {
            },
            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.processSendDataPackage(_response);
        });
    }

    protected processSendDataPackage(response: AxiosResponse): Promise<void> {
        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;
            return Promise.resolve<void>(null as any);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<void>(null as any);
    }

    /**
     * 获取指定IP地址接收的数据列表
     * @param address (optional) IP地址
     * @param taskID (optional) 任务ID
     */
    getRecvDataArray(address: string | undefined, taskID: number | undefined, cancelToken?: CancelToken): Promise<UDPData[]> {
        let url_ = this.baseUrl + "/api/UDP/GetRecvDataArray?";
        if (address === null)
            throw new Error("The parameter 'address' cannot be null.");
        else if (address !== undefined)
            url_ += "address=" + encodeURIComponent("" + address) + "&";
        if (taskID === null)
            throw new Error("The parameter 'taskID' cannot be null.");
        else if (taskID !== undefined)
            url_ += "taskID=" + encodeURIComponent("" + taskID) + "&";
        url_ = url_.replace(/[?&]$/, "");

        let options_: AxiosRequestConfig = {
            method: "GET",
            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.processGetRecvDataArray(_response);
        });
    }

    protected processGetRecvDataArray(response: AxiosResponse): Promise<UDPData[]> {
        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;
            if (Array.isArray(resultData200)) {
                result200 = [] as any;
                for (let item of resultData200)
                    result200!.push(UDPData.fromJS(item));
            }
            else {
                result200 = <any>null;
            }
            return Promise.resolve<UDPData[]>(result200);

        } else if (status === 500) {
            const _responseText = response.data;
            return throwException("A server side error occurred.", status, _responseText, _headers);

        } else if (status !== 200 && status !== 204) {
            const _responseText = response.data;
            return throwException("An unexpected server error occurred.", status, _responseText, _headers);
        }
        return Promise.resolve<UDPData[]>(null as any);
    }
}

/** 表示视频流服务的运行状态 */
export class VideoStreamServiceStatus implements IVideoStreamServiceStatus {
    /** 服务是否正在运行 */
    isRunning!: boolean;
    /** 服务监听的端口号 */
    serverPort!: number;
    /** 当前连接的客户端端点列表 */
    clientEndpoints!: VideoStreamEndpoint[];
    /** 当前连接的客户端数量 */
    connectedClientsNum!: number;

    constructor(data?: IVideoStreamServiceStatus) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
        if (!data) {
            this.clientEndpoints = [];
        }
    }

    init(_data?: any) {
        if (_data) {
            this.isRunning = _data["isRunning"];
            this.serverPort = _data["serverPort"];
            if (Array.isArray(_data["clientEndpoints"])) {
                this.clientEndpoints = [] as any;
                for (let item of _data["clientEndpoints"])
                    this.clientEndpoints!.push(VideoStreamEndpoint.fromJS(item));
            }
            this.connectedClientsNum = _data["connectedClientsNum"];
        }
    }

    static fromJS(data: any): VideoStreamServiceStatus {
        data = typeof data === 'object' ? data : {};
        let result = new VideoStreamServiceStatus();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["isRunning"] = this.isRunning;
        data["serverPort"] = this.serverPort;
        if (Array.isArray(this.clientEndpoints)) {
            data["clientEndpoints"] = [];
            for (let item of this.clientEndpoints)
                data["clientEndpoints"].push(item ? item.toJSON() : <any>undefined);
        }
        data["connectedClientsNum"] = this.connectedClientsNum;
        return data;
    }
}

/** 表示视频流服务的运行状态 */
export interface IVideoStreamServiceStatus {
    /** 服务是否正在运行 */
    isRunning: boolean;
    /** 服务监听的端口号 */
    serverPort: number;
    /** 当前连接的客户端端点列表 */
    clientEndpoints: VideoStreamEndpoint[];
    /** 当前连接的客户端数量 */
    connectedClientsNum: number;
}

/** 表示摄像头连接状态信息 */
export class VideoStreamEndpoint implements IVideoStreamEndpoint {
    boardId!: string;
    mjpegUrl!: string;
    videoUrl!: string;
    snapshotUrl!: string;
    htmlUrl!: string;
    usbCameraUrl!: string;
    isEnabled!: boolean;
    /** 视频流的帧率（FPS） */
    frameRate!: number;
    frameWidth!: number;
    frameHeight!: number;
    /** 视频分辨率（如 640x480） */
    resolution!: string;

    constructor(data?: IVideoStreamEndpoint) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.boardId = _data["boardId"];
            this.mjpegUrl = _data["mjpegUrl"];
            this.videoUrl = _data["videoUrl"];
            this.snapshotUrl = _data["snapshotUrl"];
            this.htmlUrl = _data["htmlUrl"];
            this.usbCameraUrl = _data["usbCameraUrl"];
            this.isEnabled = _data["isEnabled"];
            this.frameRate = _data["frameRate"];
            this.frameWidth = _data["frameWidth"];
            this.frameHeight = _data["frameHeight"];
            this.resolution = _data["resolution"];
        }
    }

    static fromJS(data: any): VideoStreamEndpoint {
        data = typeof data === 'object' ? data : {};
        let result = new VideoStreamEndpoint();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["boardId"] = this.boardId;
        data["mjpegUrl"] = this.mjpegUrl;
        data["videoUrl"] = this.videoUrl;
        data["snapshotUrl"] = this.snapshotUrl;
        data["htmlUrl"] = this.htmlUrl;
        data["usbCameraUrl"] = this.usbCameraUrl;
        data["isEnabled"] = this.isEnabled;
        data["frameRate"] = this.frameRate;
        data["frameWidth"] = this.frameWidth;
        data["frameHeight"] = this.frameHeight;
        data["resolution"] = this.resolution;
        return data;
    }
}

/** 表示摄像头连接状态信息 */
export interface IVideoStreamEndpoint {
    boardId: string;
    mjpegUrl: string;
    videoUrl: string;
    snapshotUrl: string;
    htmlUrl: string;
    usbCameraUrl: string;
    isEnabled: boolean;
    /** 视频流的帧率（FPS） */
    frameRate: number;
    frameWidth: number;
    frameHeight: number;
    /** 视频分辨率（如 640x480） */
    resolution: string;
}

export class Exception implements IException {
    declare message: string;
    innerException?: Exception | undefined;
    source?: string | undefined;
    stackTrace?: string | undefined;

    constructor(data?: IException) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.message = _data["Message"];
            this.innerException = _data["InnerException"] ? Exception.fromJS(_data["InnerException"]) : <any>undefined;
            this.source = _data["Source"];
            this.stackTrace = _data["StackTrace"];
        }
    }

    static fromJS(data: any): Exception {
        data = typeof data === 'object' ? data : {};
        let result = new Exception();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["Message"] = this.message;
        data["InnerException"] = this.innerException ? this.innerException.toJSON() : <any>undefined;
        data["Source"] = this.source;
        data["StackTrace"] = this.stackTrace;
        return data;
    }
}

export interface IException {
    message: string;
    innerException?: Exception | undefined;
    source?: string | undefined;
    stackTrace?: string | undefined;
}

/** 分辨率配置请求模型 */
export class ResolutionConfigRequest implements IResolutionConfigRequest {
    /** 宽度 */
    width!: number;
    /** 高度 */
    height!: number;

    constructor(data?: IResolutionConfigRequest) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.width = _data["width"];
            this.height = _data["height"];
        }
    }

    static fromJS(data: any): ResolutionConfigRequest {
        data = typeof data === 'object' ? data : {};
        let result = new ResolutionConfigRequest();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["width"] = this.width;
        data["height"] = this.height;
        return data;
    }
}

/** 分辨率配置请求模型 */
export interface IResolutionConfigRequest {
    /** 宽度 */
    width: number;
    /** 高度 */
    height: number;
}

export class AvailableResolutionsResponse implements IAvailableResolutionsResponse {
    width!: number;
    height!: number;
    name!: string;
    value!: string;

    constructor(data?: IAvailableResolutionsResponse) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.width = _data["width"];
            this.height = _data["height"];
            this.name = _data["name"];
            this.value = _data["value"];
        }
    }

    static fromJS(data: any): AvailableResolutionsResponse {
        data = typeof data === 'object' ? data : {};
        let result = new AvailableResolutionsResponse();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["width"] = this.width;
        data["height"] = this.height;
        data["name"] = this.name;
        data["value"] = this.value;
        return data;
    }
}

export interface IAvailableResolutionsResponse {
    width: number;
    height: number;
    name: string;
    value: string;
}

export class ProblemDetails implements IProblemDetails {
    type?: string | undefined;
    title?: string | undefined;
    status?: number | undefined;
    detail?: string | undefined;
    instance?: string | undefined;
    extensions!: { [key: string]: any; };

    [key: string]: any;

    constructor(data?: IProblemDetails) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
        if (!data) {
            this.extensions = {};
        }
    }

    init(_data?: any) {
        if (_data) {
            for (var property in _data) {
                if (_data.hasOwnProperty(property))
                    this[property] = _data[property];
            }
            this.type = _data["type"];
            this.title = _data["title"];
            this.status = _data["status"];
            this.detail = _data["detail"];
            this.instance = _data["instance"];
            if (_data["extensions"]) {
                this.extensions = {} as any;
                for (let key in _data["extensions"]) {
                    if (_data["extensions"].hasOwnProperty(key))
                        (<any>this.extensions)![key] = _data["extensions"][key];
                }
            }
        }
    }

    static fromJS(data: any): ProblemDetails {
        data = typeof data === 'object' ? data : {};
        let result = new ProblemDetails();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        for (var property in this) {
            if (this.hasOwnProperty(property))
                data[property] = this[property];
        }
        data["type"] = this.type;
        data["title"] = this.title;
        data["status"] = this.status;
        data["detail"] = this.detail;
        data["instance"] = this.instance;
        if (this.extensions) {
            data["extensions"] = {};
            for (let key in this.extensions) {
                if (this.extensions.hasOwnProperty(key))
                    (<any>data["extensions"])[key] = (<any>this.extensions)[key];
            }
        }
        return data;
    }
}

export interface IProblemDetails {
    type?: string | undefined;
    title?: string | undefined;
    status?: number | undefined;
    detail?: string | undefined;
    instance?: string | undefined;
    extensions: { [key: string]: any; };

    [key: string]: any;
}

/** [TODO:description] */
export class UserInfo implements IUserInfo {
    /** 用户的唯一标识符 */
    id!: string;
    /** 用户的名称 */
    name!: string;
    /** 用户的电子邮箱 */
    eMail!: string;
    /** 用户关联的板卡ID */
    boardID!: string;
    /** 用户绑定板子的过期时间 */
    boardExpireTime?: Date | undefined;

    constructor(data?: IUserInfo) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.id = _data["id"];
            this.name = _data["name"];
            this.eMail = _data["eMail"];
            this.boardID = _data["boardID"];
            this.boardExpireTime = _data["boardExpireTime"] ? new Date(_data["boardExpireTime"].toString()) : <any>undefined;
        }
    }

    static fromJS(data: any): UserInfo {
        data = typeof data === 'object' ? data : {};
        let result = new UserInfo();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["id"] = this.id;
        data["name"] = this.name;
        data["eMail"] = this.eMail;
        data["boardID"] = this.boardID;
        data["boardExpireTime"] = this.boardExpireTime ? this.boardExpireTime.toISOString() : <any>undefined;
        return data;
    }
}

/** [TODO:description] */
export interface IUserInfo {
    /** 用户的唯一标识符 */
    id: string;
    /** 用户的名称 */
    name: string;
    /** 用户的电子邮箱 */
    eMail: string;
    /** 用户关联的板卡ID */
    boardID: string;
    /** 用户绑定板子的过期时间 */
    boardExpireTime?: Date | undefined;
}

/** FPGA 板子类，表示板子信息 */
export class Board implements IBoard {
    /** FPGA 板子的唯一标识符 */
    id!: string;
    /** FPGA 板子的名称 */
    boardName!: string;
    /** FPGA 板子的IP地址 */
    ipAddr!: string;
    /** FPGA 板子的MAC地址 */
    macAddr!: string;
    /** FPGA 板子的通信端口 */
    port!: number;
    /** FPGA 板子的当前状态 */
    status!: BoardStatus;
    /** 占用该板子的用户的唯一标识符 */
    occupiedUserID!: string;
    /** 占用该板子的用户的用户名 */
    occupiedUserName?: string | undefined;
    /** FPGA 板子的固件版本号 */
    firmVersion!: string;

    constructor(data?: IBoard) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.id = _data["id"];
            this.boardName = _data["boardName"];
            this.ipAddr = _data["ipAddr"];
            this.macAddr = _data["macAddr"];
            this.port = _data["port"];
            this.status = _data["status"];
            this.occupiedUserID = _data["occupiedUserID"];
            this.occupiedUserName = _data["occupiedUserName"];
            this.firmVersion = _data["firmVersion"];
        }
    }

    static fromJS(data: any): Board {
        data = typeof data === 'object' ? data : {};
        let result = new Board();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["id"] = this.id;
        data["boardName"] = this.boardName;
        data["ipAddr"] = this.ipAddr;
        data["macAddr"] = this.macAddr;
        data["port"] = this.port;
        data["status"] = this.status;
        data["occupiedUserID"] = this.occupiedUserID;
        data["occupiedUserName"] = this.occupiedUserName;
        data["firmVersion"] = this.firmVersion;
        return data;
    }
}

/** FPGA 板子类，表示板子信息 */
export interface IBoard {
    /** FPGA 板子的唯一标识符 */
    id: string;
    /** FPGA 板子的名称 */
    boardName: string;
    /** FPGA 板子的IP地址 */
    ipAddr: string;
    /** FPGA 板子的MAC地址 */
    macAddr: string;
    /** FPGA 板子的通信端口 */
    port: number;
    /** FPGA 板子的当前状态 */
    status: BoardStatus;
    /** 占用该板子的用户的唯一标识符 */
    occupiedUserID: string;
    /** 占用该板子的用户的用户名 */
    occupiedUserName?: string | undefined;
    /** FPGA 板子的固件版本号 */
    firmVersion: string;
}

/** FPGA 板子状态枚举 */
export enum BoardStatus {
    Disabled = 0,
    Busy = 1,
    Available = 2,
}

export class SystemException extends Exception implements ISystemException {

    constructor(data?: ISystemException) {
        super(data);
    }

    init(_data?: any) {
        super.init(_data);
    }

    static fromJS(data: any): SystemException {
        data = typeof data === 'object' ? data : {};
        let result = new SystemException();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        super.toJSON(data);
        return data;
    }
}

export interface ISystemException extends IException {
}

export class ArgumentException extends SystemException implements IArgumentException {
    declare message: string;
    paramName?: string | undefined;

    constructor(data?: IArgumentException) {
        super(data);
    }

    init(_data?: any) {
        super.init(_data);
        if (_data) {
            this.message = _data["Message"];
            this.paramName = _data["ParamName"];
        }
    }

    static fromJS(data: any): ArgumentException {
        data = typeof data === 'object' ? data : {};
        let result = new ArgumentException();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["Message"] = this.message;
        data["ParamName"] = this.paramName;
        super.toJSON(data);
        return data;
    }
}

export interface IArgumentException extends ISystemException {
    message: string;
    paramName?: string | undefined;
}

/** 信号捕获模式枚举 */
export enum CaptureMode {
    None = 0,
    Logic0 = 1,
    Logic1 = 2,
    Rise = 3,
    Fall = 4,
}

/** 调试器整体配置信息 */
export class DebuggerConfig implements IDebuggerConfig {
    /** 时钟频率 */
    clkFreq!: number;
    /** 总端口数量 */
    totalPortNum!: number;
    /** 捕获深度（采样点数） */
    captureDepth!: number;
    /** 触发器数量 */
    triggerNum!: number;
    /** 所有信号通道的配置信息 */
    channelConfigs!: ChannelConfig[];

    constructor(data?: IDebuggerConfig) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
        if (!data) {
            this.channelConfigs = [];
        }
    }

    init(_data?: any) {
        if (_data) {
            this.clkFreq = _data["clkFreq"];
            this.totalPortNum = _data["totalPortNum"];
            this.captureDepth = _data["captureDepth"];
            this.triggerNum = _data["triggerNum"];
            if (Array.isArray(_data["channelConfigs"])) {
                this.channelConfigs = [] as any;
                for (let item of _data["channelConfigs"])
                    this.channelConfigs!.push(ChannelConfig.fromJS(item));
            }
        }
    }

    static fromJS(data: any): DebuggerConfig {
        data = typeof data === 'object' ? data : {};
        let result = new DebuggerConfig();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["clkFreq"] = this.clkFreq;
        data["totalPortNum"] = this.totalPortNum;
        data["captureDepth"] = this.captureDepth;
        data["triggerNum"] = this.triggerNum;
        if (Array.isArray(this.channelConfigs)) {
            data["channelConfigs"] = [];
            for (let item of this.channelConfigs)
                data["channelConfigs"].push(item ? item.toJSON() : <any>undefined);
        }
        return data;
    }
}

/** 调试器整体配置信息 */
export interface IDebuggerConfig {
    /** 时钟频率 */
    clkFreq: number;
    /** 总端口数量 */
    totalPortNum: number;
    /** 捕获深度（采样点数） */
    captureDepth: number;
    /** 触发器数量 */
    triggerNum: number;
    /** 所有信号通道的配置信息 */
    channelConfigs: ChannelConfig[];
}

/** 表示单个信号通道的配置信息 */
export class ChannelConfig implements IChannelConfig {
    /** 通道名称 */
    name!: string;
    /** 通道显示颜色（如前端波形显示用） */
    color!: string;
    /** 通道信号线宽度（位数） */
    wireWidth!: number;
    /** 信号线在父端口中的起始索引（bit） */
    wireStartIndex!: number;
    /** 父端口编号 */
    parentPort!: number;
    /** 捕获模式（如上升沿、下降沿等） */
    mode!: CaptureMode;

    constructor(data?: IChannelConfig) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.name = _data["name"];
            this.color = _data["color"];
            this.wireWidth = _data["wireWidth"];
            this.wireStartIndex = _data["wireStartIndex"];
            this.parentPort = _data["parentPort"];
            this.mode = _data["mode"];
        }
    }

    static fromJS(data: any): ChannelConfig {
        data = typeof data === 'object' ? data : {};
        let result = new ChannelConfig();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["name"] = this.name;
        data["color"] = this.color;
        data["wireWidth"] = this.wireWidth;
        data["wireStartIndex"] = this.wireStartIndex;
        data["parentPort"] = this.parentPort;
        data["mode"] = this.mode;
        return data;
    }
}

/** 表示单个信号通道的配置信息 */
export interface IChannelConfig {
    /** 通道名称 */
    name: string;
    /** 通道显示颜色（如前端波形显示用） */
    color: string;
    /** 通道信号线宽度（位数） */
    wireWidth: number;
    /** 信号线在父端口中的起始索引（bit） */
    wireStartIndex: number;
    /** 父端口编号 */
    parentPort: number;
    /** 捕获模式（如上升沿、下降沿等） */
    mode: CaptureMode;
}

/** 单个通道的捕获数据 */
export class ChannelCaptureData implements IChannelCaptureData {
    /** 通道名称 */
    name!: string;
    /** 通道捕获到的数据（Base64编码的UInt32数组） */
    data!: string;

    constructor(data?: IChannelCaptureData) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.name = _data["name"];
            this.data = _data["data"];
        }
    }

    static fromJS(data: any): ChannelCaptureData {
        data = typeof data === 'object' ? data : {};
        let result = new ChannelCaptureData();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["name"] = this.name;
        data["data"] = this.data;
        return data;
    }
}

/** 单个通道的捕获数据 */
export interface IChannelCaptureData {
    /** 通道名称 */
    name: string;
    /** 通道捕获到的数据（Base64编码的UInt32数组） */
    data: string;
}

/** 实验信息 */
export class ExamInfo implements IExamInfo {
    /** 实验的唯一标识符 */
    id!: string;
    /** 实验名称 */
    name!: string;
    /** 实验描述 */
    description!: string;
    /** 实验创建时间 */
    createdTime!: Date;
    /** 实验最后更新时间 */
    updatedTime!: Date;
    /** 实验标签 */
    tags!: string[];
    /** 实验难度（1-5） */
    difficulty!: number;
    /** 普通用户是否可见 */
    isVisibleToUsers!: boolean;

    constructor(data?: IExamInfo) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
        if (!data) {
            this.tags = [];
        }
    }

    init(_data?: any) {
        if (_data) {
            this.id = _data["id"];
            this.name = _data["name"];
            this.description = _data["description"];
            this.createdTime = _data["createdTime"] ? new Date(_data["createdTime"].toString()) : <any>undefined;
            this.updatedTime = _data["updatedTime"] ? new Date(_data["updatedTime"].toString()) : <any>undefined;
            if (Array.isArray(_data["tags"])) {
                this.tags = [] as any;
                for (let item of _data["tags"])
                    this.tags!.push(item);
            }
            this.difficulty = _data["difficulty"];
            this.isVisibleToUsers = _data["isVisibleToUsers"];
        }
    }

    static fromJS(data: any): ExamInfo {
        data = typeof data === 'object' ? data : {};
        let result = new ExamInfo();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["id"] = this.id;
        data["name"] = this.name;
        data["description"] = this.description;
        data["createdTime"] = this.createdTime ? this.createdTime.toISOString() : <any>undefined;
        data["updatedTime"] = this.updatedTime ? this.updatedTime.toISOString() : <any>undefined;
        if (Array.isArray(this.tags)) {
            data["tags"] = [];
            for (let item of this.tags)
                data["tags"].push(item);
        }
        data["difficulty"] = this.difficulty;
        data["isVisibleToUsers"] = this.isVisibleToUsers;
        return data;
    }
}

/** 实验信息 */
export interface IExamInfo {
    /** 实验的唯一标识符 */
    id: string;
    /** 实验名称 */
    name: string;
    /** 实验描述 */
    description: string;
    /** 实验创建时间 */
    createdTime: Date;
    /** 实验最后更新时间 */
    updatedTime: Date;
    /** 实验标签 */
    tags: string[];
    /** 实验难度（1-5） */
    difficulty: number;
    /** 普通用户是否可见 */
    isVisibleToUsers: boolean;
}

/** 统一的实验数据传输对象 */
export class ExamDto implements IExamDto {
    /** 实验的唯一标识符 */
    id!: string;
    /** 实验名称 */
    name!: string;
    /** 实验描述 */
    description!: string;
    /** 实验标签 */
    tags!: string[];
    /** 实验难度（1-5） */
    difficulty!: number;
    /** 普通用户是否可见 */
    isVisibleToUsers!: boolean;

    constructor(data?: IExamDto) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
        if (!data) {
            this.tags = [];
        }
    }

    init(_data?: any) {
        if (_data) {
            this.id = _data["id"];
            this.name = _data["name"];
            this.description = _data["description"];
            if (Array.isArray(_data["tags"])) {
                this.tags = [] as any;
                for (let item of _data["tags"])
                    this.tags!.push(item);
            }
            this.difficulty = _data["difficulty"];
            this.isVisibleToUsers = _data["isVisibleToUsers"];
        }
    }

    static fromJS(data: any): ExamDto {
        data = typeof data === 'object' ? data : {};
        let result = new ExamDto();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["id"] = this.id;
        data["name"] = this.name;
        data["description"] = this.description;
        if (Array.isArray(this.tags)) {
            data["tags"] = [];
            for (let item of this.tags)
                data["tags"].push(item);
        }
        data["difficulty"] = this.difficulty;
        data["isVisibleToUsers"] = this.isVisibleToUsers;
        return data;
    }
}

/** 统一的实验数据传输对象 */
export interface IExamDto {
    /** 实验的唯一标识符 */
    id: string;
    /** 实验名称 */
    name: string;
    /** 实验描述 */
    description: string;
    /** 实验标签 */
    tags: string[];
    /** 实验难度（1-5） */
    difficulty: number;
    /** 普通用户是否可见 */
    isVisibleToUsers: boolean;
}

export class Commit implements ICommit {
    /** 资源的唯一标识符 */
    id!: string;
    /** 上传资源的用户ID */
    userID!: string;
    /** 所属实验ID */
    examID?: string | undefined;
    type!: CommitType;
    resourceID!: string;
    createdAt!: Date;

    constructor(data?: ICommit) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.id = _data["id"];
            this.userID = _data["userID"];
            this.examID = _data["examID"];
            this.type = _data["type"];
            this.resourceID = _data["resourceID"];
            this.createdAt = _data["createdAt"] ? new Date(_data["createdAt"].toString()) : <any>undefined;
        }
    }

    static fromJS(data: any): Commit {
        data = typeof data === 'object' ? data : {};
        let result = new Commit();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["id"] = this.id;
        data["userID"] = this.userID;
        data["examID"] = this.examID;
        data["type"] = this.type;
        data["resourceID"] = this.resourceID;
        data["createdAt"] = this.createdAt ? this.createdAt.toISOString() : <any>undefined;
        return data;
    }
}

export interface ICommit {
    /** 资源的唯一标识符 */
    id: string;
    /** 上传资源的用户ID */
    userID: string;
    /** 所属实验ID */
    examID?: string | undefined;
    type: CommitType;
    resourceID: string;
    createdAt: Date;
}

export enum CommitType {
    Homework = 0,
    Project = 1,
    Markdown = 2,
}

export class HdmiVideoStreamEndpoint implements IHdmiVideoStreamEndpoint {
    boardId!: string;
    mjpegUrl!: string;
    videoUrl!: string;
    snapshotUrl!: string;

    constructor(data?: IHdmiVideoStreamEndpoint) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.boardId = _data["boardId"];
            this.mjpegUrl = _data["mjpegUrl"];
            this.videoUrl = _data["videoUrl"];
            this.snapshotUrl = _data["snapshotUrl"];
        }
    }

    static fromJS(data: any): HdmiVideoStreamEndpoint {
        data = typeof data === 'object' ? data : {};
        let result = new HdmiVideoStreamEndpoint();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["boardId"] = this.boardId;
        data["mjpegUrl"] = this.mjpegUrl;
        data["videoUrl"] = this.videoUrl;
        data["snapshotUrl"] = this.snapshotUrl;
        return data;
    }
}

export interface IHdmiVideoStreamEndpoint {
    boardId: string;
    mjpegUrl: string;
    videoUrl: string;
    snapshotUrl: string;
}

/** 逻辑分析仪运行状态枚举 */
export enum CaptureStatus {
    None = 0,
    CaptureOn = 1,
    CaptureForce = 256,
    CaptureBusy = 65536,
    CaptureDone = 16777216,
}

/** 全局触发模式枚举，定义多路信号触发条件的逻辑组合方式 */
export enum GlobalCaptureMode {
    AND = 0,
    OR = 1,
    NAND = 2,
    NOR = 3,
}

/** 信号M的操作符枚举 */
export enum SignalOperator {
    Equal = 0,
    NotEqual = 1,
    LessThan = 2,
    LessThanOrEqual = 3,
    GreaterThan = 4,
    GreaterThanOrEqual = 5,
}

/** 信号M的值枚举 */
export enum SignalValue {
    Logic0 = 0,
    Logic1 = 1,
    NotCare = 2,
    Rise = 3,
    Fall = 4,
    RiseOrFall = 5,
    NoChange = 6,
    SomeNumber = 7,
}

/** 逻辑分析仪有效通道数 */
export enum AnalyzerChannelDiv {
    ONE = 0,
    TWO = 1,
    FOUR = 2,
    EIGHT = 3,
    XVI = 4,
    XXXII = 5,
}

/** 逻辑分析仪采样时钟分频系数 */
export enum AnalyzerClockDiv {
    DIV1 = 0,
    DIV2 = 1,
    DIV4 = 2,
    DIV8 = 3,
    DIV16 = 4,
    DIV32 = 5,
    DIV64 = 6,
    DIV128 = 7,
}

/** 捕获配置 */
export class CaptureConfig implements ICaptureConfig {
    /** 全局触发模式 */
    globalMode!: GlobalCaptureMode;
    /** 捕获深度 */
    captureLength!: number;
    /** 预采样深度 */
    preCaptureLength!: number;
    /** 有效通道 */
    channelDiv!: AnalyzerChannelDiv;
    /** 时钟分频系数 */
    clockDiv!: AnalyzerClockDiv;
    /** 信号触发配置列表 */
    signalConfigs!: SignalTriggerConfig[];

    constructor(data?: ICaptureConfig) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
        if (!data) {
            this.signalConfigs = [];
        }
    }

    init(_data?: any) {
        if (_data) {
            this.globalMode = _data["globalMode"];
            this.captureLength = _data["captureLength"];
            this.preCaptureLength = _data["preCaptureLength"];
            this.channelDiv = _data["channelDiv"];
            this.clockDiv = _data["clockDiv"];
            if (Array.isArray(_data["signalConfigs"])) {
                this.signalConfigs = [] as any;
                for (let item of _data["signalConfigs"])
                    this.signalConfigs!.push(SignalTriggerConfig.fromJS(item));
            }
        }
    }

    static fromJS(data: any): CaptureConfig {
        data = typeof data === 'object' ? data : {};
        let result = new CaptureConfig();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["globalMode"] = this.globalMode;
        data["captureLength"] = this.captureLength;
        data["preCaptureLength"] = this.preCaptureLength;
        data["channelDiv"] = this.channelDiv;
        data["clockDiv"] = this.clockDiv;
        if (Array.isArray(this.signalConfigs)) {
            data["signalConfigs"] = [];
            for (let item of this.signalConfigs)
                data["signalConfigs"].push(item ? item.toJSON() : <any>undefined);
        }
        return data;
    }
}

/** 捕获配置 */
export interface ICaptureConfig {
    /** 全局触发模式 */
    globalMode: GlobalCaptureMode;
    /** 捕获深度 */
    captureLength: number;
    /** 预采样深度 */
    preCaptureLength: number;
    /** 有效通道 */
    channelDiv: AnalyzerChannelDiv;
    /** 时钟分频系数 */
    clockDiv: AnalyzerClockDiv;
    /** 信号触发配置列表 */
    signalConfigs: SignalTriggerConfig[];
}

/** 信号触发配置 */
export class SignalTriggerConfig implements ISignalTriggerConfig {
    /** 信号索引 (0-7) */
    signalIndex!: number;
    /** 操作符 */
    operator!: SignalOperator;
    /** 信号值 */
    value!: SignalValue;

    constructor(data?: ISignalTriggerConfig) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.signalIndex = _data["signalIndex"];
            this.operator = _data["operator"];
            this.value = _data["value"];
        }
    }

    static fromJS(data: any): SignalTriggerConfig {
        data = typeof data === 'object' ? data : {};
        let result = new SignalTriggerConfig();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["signalIndex"] = this.signalIndex;
        data["operator"] = this.operator;
        data["value"] = this.value;
        return data;
    }
}

/** 信号触发配置 */
export interface ISignalTriggerConfig {
    /** 信号索引 (0-7) */
    signalIndex: number;
    /** 操作符 */
    operator: SignalOperator;
    /** 信号值 */
    value: SignalValue;
}

/** 网络配置数据传输对象 */
export class NetworkConfigDto implements INetworkConfigDto {
    /** 主机IP地址 */
    hostIP?: string | undefined;
    /** 板卡IP地址 */
    boardIP?: string | undefined;
    /** 主机MAC地址 */
    hostMAC?: string | undefined;
    /** 板卡MAC地址 */
    boardMAC?: string | undefined;

    constructor(data?: INetworkConfigDto) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.hostIP = _data["hostIP"];
            this.boardIP = _data["boardIP"];
            this.hostMAC = _data["hostMAC"];
            this.boardMAC = _data["boardMAC"];
        }
    }

    static fromJS(data: any): NetworkConfigDto {
        data = typeof data === 'object' ? data : {};
        let result = new NetworkConfigDto();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["hostIP"] = this.hostIP;
        data["boardIP"] = this.boardIP;
        data["hostMAC"] = this.hostMAC;
        data["boardMAC"] = this.boardMAC;
        return data;
    }
}

/** 网络配置数据传输对象 */
export interface INetworkConfigDto {
    /** 主机IP地址 */
    hostIP?: string | undefined;
    /** 板卡IP地址 */
    boardIP?: string | undefined;
    /** 主机MAC地址 */
    hostMAC?: string | undefined;
    /** 板卡MAC地址 */
    boardMAC?: string | undefined;
}

/** 网络接口信息数据传输对象 */
export class NetworkInterfaceDto implements INetworkInterfaceDto {
    /** 网络接口名称 */
    name!: string;
    /** 网络接口描述 */
    description!: string;
    /** 网络接口类型 */
    type!: string;
    /** 网络接口状态 */
    status!: string;
    /** IP地址列表 */
    ipAddresses!: string[];
    /** MAC地址 */
    macAddress!: string;

    constructor(data?: INetworkInterfaceDto) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
        if (!data) {
            this.ipAddresses = [];
        }
    }

    init(_data?: any) {
        if (_data) {
            this.name = _data["name"];
            this.description = _data["description"];
            this.type = _data["type"];
            this.status = _data["status"];
            if (Array.isArray(_data["ipAddresses"])) {
                this.ipAddresses = [] as any;
                for (let item of _data["ipAddresses"])
                    this.ipAddresses!.push(item);
            }
            this.macAddress = _data["macAddress"];
        }
    }

    static fromJS(data: any): NetworkInterfaceDto {
        data = typeof data === 'object' ? data : {};
        let result = new NetworkInterfaceDto();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["name"] = this.name;
        data["description"] = this.description;
        data["type"] = this.type;
        data["status"] = this.status;
        if (Array.isArray(this.ipAddresses)) {
            data["ipAddresses"] = [];
            for (let item of this.ipAddresses)
                data["ipAddresses"].push(item);
        }
        data["macAddress"] = this.macAddress;
        return data;
    }
}

/** 网络接口信息数据传输对象 */
export interface INetworkInterfaceDto {
    /** 网络接口名称 */
    name: string;
    /** 网络接口描述 */
    description: string;
    /** 网络接口类型 */
    type: string;
    /** 网络接口状态 */
    status: string;
    /** IP地址列表 */
    ipAddresses: string[];
    /** MAC地址 */
    macAddress: string;
}

/** 示波器完整配置 */
export class OscilloscopeFullConfig implements IOscilloscopeFullConfig {
    /** 是否启动捕获 */
    captureEnabled!: boolean;
    /** 触发电平（0-255） */
    triggerLevel!: number;
    /** 触发边沿（true为上升沿，false为下降沿） */
    triggerRisingEdge!: boolean;
    /** 水平偏移量（0-1023） */
    horizontalShift!: number;
    /** 抽样率（0-1023） */
    decimationRate!: number;
    /** 是否自动刷新RAM */
    autoRefreshRAM!: boolean;

    constructor(data?: IOscilloscopeFullConfig) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.captureEnabled = _data["captureEnabled"];
            this.triggerLevel = _data["triggerLevel"];
            this.triggerRisingEdge = _data["triggerRisingEdge"];
            this.horizontalShift = _data["horizontalShift"];
            this.decimationRate = _data["decimationRate"];
            this.autoRefreshRAM = _data["autoRefreshRAM"];
        }
    }

    static fromJS(data: any): OscilloscopeFullConfig {
        data = typeof data === 'object' ? data : {};
        let result = new OscilloscopeFullConfig();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["captureEnabled"] = this.captureEnabled;
        data["triggerLevel"] = this.triggerLevel;
        data["triggerRisingEdge"] = this.triggerRisingEdge;
        data["horizontalShift"] = this.horizontalShift;
        data["decimationRate"] = this.decimationRate;
        data["autoRefreshRAM"] = this.autoRefreshRAM;
        return data;
    }
}

/** 示波器完整配置 */
export interface IOscilloscopeFullConfig {
    /** 是否启动捕获 */
    captureEnabled: boolean;
    /** 触发电平（0-255） */
    triggerLevel: number;
    /** 触发边沿（true为上升沿，false为下降沿） */
    triggerRisingEdge: boolean;
    /** 水平偏移量（0-1023） */
    horizontalShift: number;
    /** 抽样率（0-1023） */
    decimationRate: number;
    /** 是否自动刷新RAM */
    autoRefreshRAM: boolean;
}

/** 示波器状态和数据 */
export class OscilloscopeDataResponse implements IOscilloscopeDataResponse {
    /** AD采样频率 */
    adFrequency!: number;
    /** AD采样幅度 */
    adVpp!: number;
    /** AD采样最大值 */
    adMax!: number;
    /** AD采样最小值 */
    adMin!: number;
    /** 波形数据（Base64编码） */
    waveformData!: string;

    constructor(data?: IOscilloscopeDataResponse) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.adFrequency = _data["adFrequency"];
            this.adVpp = _data["adVpp"];
            this.adMax = _data["adMax"];
            this.adMin = _data["adMin"];
            this.waveformData = _data["waveformData"];
        }
    }

    static fromJS(data: any): OscilloscopeDataResponse {
        data = typeof data === 'object' ? data : {};
        let result = new OscilloscopeDataResponse();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["adFrequency"] = this.adFrequency;
        data["adVpp"] = this.adVpp;
        data["adMax"] = this.adMax;
        data["adMin"] = this.adMin;
        data["waveformData"] = this.waveformData;
        return data;
    }
}

/** 示波器状态和数据 */
export interface IOscilloscopeDataResponse {
    /** AD采样频率 */
    adFrequency: number;
    /** AD采样幅度 */
    adVpp: number;
    /** AD采样最大值 */
    adMax: number;
    /** AD采样最小值 */
    adMin: number;
    /** 波形数据（Base64编码） */
    waveformData: string;
}

/** 资源信息类 */
export class ResourceInfo implements IResourceInfo {
    /** 资源ID */
    id!: string;
    /** 资源名称 */
    name!: string;
    /** 资源类型 */
    type!: string;
    /** 资源用途（template/user） */
    purpose!: string;
    /** 上传时间 */
    uploadTime!: Date;
    /** 所属实验ID（可选） */
    examID?: string | undefined;
    /** MIME类型 */
    mimeType?: string | undefined;

    constructor(data?: IResourceInfo) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.id = _data["id"];
            this.name = _data["name"];
            this.type = _data["type"];
            this.purpose = _data["purpose"];
            this.uploadTime = _data["uploadTime"] ? new Date(_data["uploadTime"].toString()) : <any>undefined;
            this.examID = _data["examID"];
            this.mimeType = _data["mimeType"];
        }
    }

    static fromJS(data: any): ResourceInfo {
        data = typeof data === 'object' ? data : {};
        let result = new ResourceInfo();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["id"] = this.id;
        data["name"] = this.name;
        data["type"] = this.type;
        data["purpose"] = this.purpose;
        data["uploadTime"] = this.uploadTime ? this.uploadTime.toISOString() : <any>undefined;
        data["examID"] = this.examID;
        data["mimeType"] = this.mimeType;
        return data;
    }
}

/** 资源信息类 */
export interface IResourceInfo {
    /** 资源ID */
    id: string;
    /** 资源名称 */
    name: string;
    /** 资源类型 */
    type: string;
    /** 资源用途（template/user） */
    purpose: string;
    /** 上传时间 */
    uploadTime: Date;
    /** 所属实验ID（可选） */
    examID?: string | undefined;
    /** MIME类型 */
    mimeType?: string | undefined;
}

/** Package options which to send address to read or write */
export class SendAddrPackOptions implements ISendAddrPackOptions {
    /** 突发类型 */
    burstType!: BurstType;
    /** 任务ID */
    commandID!: number;
    /** 标识写入还是读取 */
    isWrite!: boolean;
    /** 突发长度：0是32bits，255是32bits x 256 */
    burstLength!: number;
    /** 目标地址 */
    address!: number;

    constructor(data?: ISendAddrPackOptions) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.burstType = _data["burstType"];
            this.commandID = _data["commandID"];
            this.isWrite = _data["isWrite"];
            this.burstLength = _data["burstLength"];
            this.address = _data["address"];
        }
    }

    static fromJS(data: any): SendAddrPackOptions {
        data = typeof data === 'object' ? data : {};
        let result = new SendAddrPackOptions();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["burstType"] = this.burstType;
        data["commandID"] = this.commandID;
        data["isWrite"] = this.isWrite;
        data["burstLength"] = this.burstLength;
        data["address"] = this.address;
        return data;
    }
}

/** Package options which to send address to read or write */
export interface ISendAddrPackOptions {
    /** 突发类型 */
    burstType: BurstType;
    /** 任务ID */
    commandID: number;
    /** 标识写入还是读取 */
    isWrite: boolean;
    /** 突发长度：0是32bits，255是32bits x 256 */
    burstLength: number;
    /** 目标地址 */
    address: number;
}

/** Package Burst Type */
export enum BurstType {
    FixedBurst = 0,
    ExtendBurst = 1,
}

/** UDP接受数据包格式 */
export class UDPData implements IUDPData {
    /** 接受到的时间 */
    dateTime!: Date;
    /** 数据包时间戳 */
    timestamp!: number;
    /** 发送来源的IP地址 */
    address!: string;
    /** 发送来源的端口号 */
    port!: number;
    /** 任务ID */
    taskID!: number;
    /** 接受到的数据 */
    data!: string;
    /** 是否被读取过 */
    hasRead!: boolean;

    constructor(data?: IUDPData) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (<any>this)[property] = (<any>data)[property];
            }
        }
    }

    init(_data?: any) {
        if (_data) {
            this.dateTime = _data["dateTime"] ? new Date(_data["dateTime"].toString()) : <any>undefined;
            this.timestamp = _data["timestamp"];
            this.address = _data["address"];
            this.port = _data["port"];
            this.taskID = _data["taskID"];
            this.data = _data["data"];
            this.hasRead = _data["hasRead"];
        }
    }

    static fromJS(data: any): UDPData {
        data = typeof data === 'object' ? data : {};
        let result = new UDPData();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        data["dateTime"] = this.dateTime ? this.dateTime.toISOString() : <any>undefined;
        data["timestamp"] = this.timestamp;
        data["address"] = this.address;
        data["port"] = this.port;
        data["taskID"] = this.taskID;
        data["data"] = this.data;
        data["hasRead"] = this.hasRead;
        return data;
    }
}

/** UDP接受数据包格式 */
export interface IUDPData {
    /** 接受到的时间 */
    dateTime: Date;
    /** 数据包时间戳 */
    timestamp: number;
    /** 发送来源的IP地址 */
    address: string;
    /** 发送来源的端口号 */
    port: number;
    /** 任务ID */
    taskID: number;
    /** 接受到的数据 */
    data: string;
    /** 是否被读取过 */
    hasRead: boolean;
}

export interface FileParameter {
    data: any;
    fileName: string;
}

export interface FileResponse {
    data: Blob;
    status: number;
    fileName?: string;
    headers?: { [name: string]: any };
}

export class ApiException extends Error {
    message: string;
    status: number;
    response: string;
    headers: { [key: string]: any; };
    result: any;

    constructor(message: string, status: number, response: string, headers: { [key: string]: any; }, result: any) {
        super();

        this.message = message;
        this.status = status;
        this.response = response;
        this.headers = headers;
        this.result = result;
    }

    protected isApiException = true;

    static isApiException(obj: any): obj is ApiException {
        return obj.isApiException === true;
    }
}

function throwException(message: string, status: number, response: string, headers: { [key: string]: any; }, result?: any): any {
    if (result !== null && result !== undefined)
        throw result;
    else
        throw new ApiException(message, status, response, headers, null);
}

function isAxiosError(obj: any): obj is AxiosError {
    return obj && obj.isAxiosError === true;
}