A multi-interface compatible configuration method and system based on a layered structure
Patent Information
- Application Number
- CN202411164027.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2026-09-15
- Estimated Expiration
- 2044-08-23
AI Technical Summary
[0002]在测试过程中,由于不同的仪器具备不同接口类型的接口,则需要满足多接口的可兼容性,以适应不同接口类型的接口,所以,为了便于工作人员进行测试以及便于用户使用同一套软件来适配多种仪器,普遍由代码人员针对多种接口的接口协议进行兼容性配置,而不同接口所具备的功能配置等均不相同,目前,针对每种接口都选择采用单独配置,一个接口对应一个接口配置结构,每当增加新接口进入时,都需重新配置接口所具备的功能配置等,导致代码人员所需处理的代码量较大,配置过程较为繁琐
本发明提供了一种基于分层结构的多种接口兼容配置方法及系统,所述方法主要采用将接口配置结构进行分层设计,每个接口层之间均具有调用关系,通过在第一接口层的选择判断就可以激活不同种类的接口进行配置,并且,代码人员无需对功能的具体实施例进行重复配置,在增加或修改接口配置时,可以使代码人员所需处理的代码量较少,配置过程简单,提高效率。
Smart Images

Figure CN119127334B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of multi-interface compatibility technology, specifically to a multi-interface compatibility configuration method and system based on a layered structure. Background Technology
[0002] During testing, different instruments have different interface types, so it is necessary to ensure compatibility of multiple interfaces to adapt to different interface types. Therefore, in order to facilitate testing by staff and to make it easier for users to use the same software to adapt to multiple instruments, coders generally configure the interface protocols of multiple interfaces for compatibility. However, the functions and configurations of different interfaces are different. Currently, each interface is configured separately, with one interface corresponding to one interface configuration structure. Whenever a new interface is added, the functions and configurations of the interface must be reconfigured, resulting in a large amount of code that coders need to process and a cumbersome configuration process. Summary of the Invention
[0003] The purpose of this invention is to provide a multi-interface compatible configuration method and system based on a layered structure. The method mainly adopts a layered design of the interface configuration structure, with each interface layer having a calling relationship. Different types of interfaces can be activated for configuration by selecting and judging the first interface layer. Furthermore, coders do not need to repeatedly configure specific implementations of functions. When adding or modifying interface configurations, the amount of code that coders need to process is reduced, the configuration process is simple, and efficiency is improved.
[0004] To solve the above-mentioned technical problems, the present invention adopts the following solution: A multi-interface compatible configuration method based on a layered structure, the method specifically includes the following steps: S1: When the current interface information of the interface to be instantiated is received, the current interface information is substituted into the first interface layer. The interface function in the first interface layer is selected and judged according to the current interface information, so that the current interface function points to the interface to be instantiated and the corresponding interface activation instruction is generated. S2: Activate the interface in the second interface layer according to the interface activation instruction, confirm the interface activation and obtain the function call function corresponding to the interface to be instantiated; S3: Based on the current interface function and the corresponding function call function, confirm and obtain the specific implementation corresponding to the interface to be instantiated between the third and fourth interface layers with a calling relationship.
[0005] Furthermore, S3 specifically includes the following steps: S30: Based on the current interface function, point the functional module in the third interface layer to the interface to be instantiated; S31: Match the corresponding function implementation module in the fourth interface layer based on the function call function; S32: Based on the function call function in the function implementation module, call the function module corresponding to the same function call function in the fourth interface layer to confirm the specific implementation corresponding to the interface to be instantiated.
[0006] Furthermore, the third interface layer contains multiple functional modules, each containing an interface function and a function call function; while the fourth interface layer contains multiple function implementation modules, each containing a function call function. The functional module is used to make unified calls to different interfaces to be instantiated. Specifically, it points upwards to different interfaces to be instantiated through different interface functions, and at the same time, it confirms the specific implementation of the functional module downwards through the function call function.
[0007] Furthermore, in S1, the interface information includes the interface type, which includes USB and PCIE. When the interface information is substituted into the first interface layer, the interface function in the first interface layer will be selected and judged according to the interface type of the interface to be instantiated, so that the current interface function points to the current interface to be instantiated.
[0008] Furthermore, the first interface layer includes an interface type determination module, which includes several pointer determination conditions. Each pointer determination condition includes a preset interface type and an interface function. The interface function points to the current interface to be instantiated by determining whether the interface type in the current interface information is the preset interface type.
[0009] Furthermore, in S1, the interface activation instruction is used to represent the pointer result of the interface function in the first interface layer. The pointer result represents the interface to be instantiated at present. Then, the corresponding interface activation instruction is generated according to the interface to be instantiated at present.
[0010] Furthermore, the second interface layer includes multiple interface configuration modules, each corresponding to an interface type. The interface configuration module is used to call the function within the interface configuration module to configure the interface.
[0011] A multi-interface compatible configuration system based on a layered structure, comprising: Interface determination module: When the current interface information of the interface to be instantiated is received, the current interface information is substituted into the first interface layer. The interface function in the first interface layer is selected and judged according to the current interface information, so that the current interface function points to the interface to be instantiated and the corresponding interface activation instruction is generated. Interface Function Confirmation Module: Activates the interface in the second interface layer according to the interface activation instruction, confirms the interface activation, and obtains the function call corresponding to the interface to be instantiated. Interface Function Configuration Module: Based on the current interface function and the corresponding function call function, the module confirms and obtains the specific implementation corresponding to the interface to be instantiated between the third and fourth interface layers with a calling relationship.
[0012] Furthermore, the interface function configuration module also includes the following: Interface Function Confirmation Module: Based on the current interface function, the functional modules in the third interface layer are pointed to the interface to be instantiated. Interface function implementation confirmation module: Matches the corresponding function implementation module in the fourth interface layer based on the function call function; Interface function call module: Based on the function call function in the function implementation module, the module corresponding to the same function call function in the fourth interface layer is called to confirm the specific implementation corresponding to the interface to be instantiated.
[0013] The beneficial effects of this invention are: This invention provides a multi-interface compatible configuration method and system based on a layered structure. The method mainly adopts a layered design of the interface configuration structure, with each interface layer having a calling relationship. Different types of interfaces can be activated for configuration by selecting and judging the first interface layer. Furthermore, coders do not need to repeatedly configure specific implementations of functions. When adding or modifying interface configurations, the amount of code that coders need to process is reduced, the configuration process is simple, and efficiency is improved. Attached Figure Description
[0014] Figure 1 This is a flowchart illustrating a multi-interface compatible configuration method based on a layered structure in Embodiment 1 of the present invention.
[0015] Figure 2 This is a schematic diagram of the interface layer call relationship in Embodiment 1 of the present invention.
[0016] Figure 3 This is a schematic diagram of the interface configuration structure in Embodiment 1 of the present invention. Detailed Implementation
[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the present invention or its application or use. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] Unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps described in these embodiments do not limit the scope of the invention.
[0019] At the same time, it should be understood that, for ease of description, the dimensions of the various parts shown in the accompanying drawings are not drawn according to actual scale.
[0020] Furthermore, for clarity and brevity, descriptions of well-known structures, functions, and configurations may have been omitted. Those skilled in the art will recognize that various changes and modifications can be made to the examples described herein without departing from the spirit and scope of this disclosure.
[0021] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.
[0022] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values.
[0023] The present invention will now be described in detail with reference to the accompanying drawings and embodiments: Example 1 like Figure 1 As shown, a multi-interface compatible configuration method based on a layered structure is described, the method specifically including the following steps: S1: When the current interface information of the interface to be instantiated is received, the current interface information is substituted into the first interface layer. The interface function in the first interface layer is selected and judged according to the current interface information, so that the current interface function points to the interface to be instantiated and the corresponding interface activation instruction is generated. S2: Activate the interface in the second interface layer according to the interface activation instruction, confirm the interface activation and obtain the function call function corresponding to the interface to be instantiated; S3: Based on the current interface function and the corresponding function call function, confirm and obtain the specific implementation corresponding to the interface to be instantiated between the third and fourth interface layers with a calling relationship.
[0024] Preferably, step S3 specifically includes the following steps: S30: Based on the current interface function, point the functional module in the third interface layer to the interface to be instantiated; S31: Match the corresponding function implementation module in the fourth interface layer based on the function call function; S32: Based on the function call function in the function implementation module, call the function module corresponding to the same function call function in the fourth interface layer to confirm the specific implementation corresponding to the interface to be instantiated.
[0025] Preferably, the third interface layer contains multiple functional modules, each containing an interface function and a function call function; while the fourth interface layer contains multiple function implementation modules, each containing a function call function. The functional module is used to make unified calls to different interfaces to be instantiated. Specifically, it points upwards to different interfaces to be instantiated through different interface functions, and at the same time, it confirms the specific implementation of the functional module downwards through the function call function.
[0026] Preferably, in S1, the interface information includes an interface type, which includes USB and PCIe. When the interface information is substituted into the first interface layer, the interface functions in the first interface layer will be selected and judged according to the interface type of the interface to be instantiated, so that the current interface function points to the current interface to be instantiated.
[0027] Preferably, the first interface layer includes an interface type determination module, which includes several pointer determination conditions. Each pointer determination condition includes a preset interface type and an interface function. The interface function points to the current interface to be instantiated by determining whether the interface type in the current interface information is the preset interface type.
[0028] Preferably, in S1, the interface activation instruction is used to represent the pointer result of the interface function in the first interface layer, and the pointer result represents the interface to be instantiated. Then, the corresponding interface activation instruction is generated according to the interface to be instantiated.
[0029] Preferably, the second interface layer includes multiple interface configuration modules, each corresponding to an interface type. The interface configuration module is used to call the function call function within the interface configuration module to configure the interface.
[0030] Based on the above principles, the present invention will be further described as follows: To reduce the amount of code required by programmers for multiple interfaces, this invention employs a layered interface configuration structure. This structure includes a first interface layer, a second interface layer, a third interface layer, and a fourth interface layer, with a calling relationship between these layers: the first interface layer points to the second interface layer, the third interface layer calls the first interface layer, and the fourth interface layer calls the third interface layer. Therefore, the fourth interface layer can call and obtain the specific implementation of the currently accessed interface's functionality, as shown in the example below. Figure 2 As shown, the first interface layer points to the second interface layer through an interface function to confirm the interface type of the current interface; the second interface layer can determine the corresponding function call function based on the current interface function, and the function call function is used to call the specific embodiment of the function; the third interface layer calls the first interface layer through the current interface function, and determines the corresponding function call function in the third interface layer based on the current interface function; the fourth interface layer calls the third interface layer through the function call function, at which point the specific embodiment of the interface function can be called on the fourth interface layer according to the function call function.
[0031] In this embodiment, based on the above-described calling relationship, the first interface layer, the second interface layer, the third interface layer, and the fourth interface layer are as follows: Figure 3 As shown, the first interface layer includes an interface type determination module, the second interface layer includes an interface configuration module 1 and an interface configuration module 2, the third interface layer includes a function module 1, a function module 2, and a function module 3, and the fourth interface layer includes a function implementation module 1, a function implementation module 2, and a function implementation module 3. Specifically, for each interface layer: In the first interface layer, the interface type determination module can select to activate either interface configuration module 1 or interface configuration module 2, causing the interface function to point to the interface of the corresponding interface type. If interface configuration module 1 is activated, the function call corresponding to the interface to be instantiated can be identified in interface configuration module 1 in the second interface layer. One interface configuration module represents the interface configuration corresponding to one interface type, and each interface can be configured with multiple different functions. Therefore, each interface configuration module can correspond to multiple function modules, meaning that one interface configuration module can contain multiple different function call functions, with one function call function corresponding to one function module. In the third interface layer, the function call function and the interface function can be used to identify the interface configuration module corresponding to interface configuration module 1. Functional modules 1 and 2 are defined. The interface function in interface configuration module 1 is the same as the interface function in functional modules 1 and 2. The function call function in interface configuration module 1 corresponds one-to-one with functional modules 1 and 2. In the fourth interface layer, a function implementation module can be identified by the function call function corresponding to different functional modules. A function implementation module is used to represent a specific implementation of a function. Each functional module corresponds to a function implementation module. A unified function call function is used for interfaces of various interface types, so that the specific implementation of the interface function is called through the unified function call function. This enables the specific implementation of the functional module to be obtained by calling the function call function downwards.
[0032] If a new interface needs to be added, simply add the interface type to the first interface layer and the basic settings for that interface to the second interface layer, which is equivalent to adding an interface configuration module. The interface configuration module can automatically make function calls from the third and fourth interface layers through function call functions, eliminating the need for staff to manually configure the interface functions. This is equivalent to extracting the function configuration file from the interface configuration structure corresponding to each interface in the existing technology, and designing the interface activation file and function configuration file in a layered manner, which are then called through a unified function call.
[0033] In this embodiment, the first interface layer includes the following: void DeviceInterface::SetInstance(Interfacelype type) if(_deviceInterface != nullptr) _deviceInterface->~DeviceInterface(); _deviceInterface = nullptr; if(type == USB) _deviceInterface =new USBDeviceInterface(); Else _deviceInterface =new VISADeviceInterface(); As can be seen, the current first interface layer includes an interface type determination module. The current interface type determination module includes two pointer judgment conditions. Each of the two pointer judgment conditions contains a preset interface type and an interface function. The preset interface type is divided into USB and VISA. The interface function is deviceInterface. If the currently connected interface is USB, then according to the pointer judgment condition, the current interface function deviceInterface is pointed to USB, that is, _deviceInterface = new USBDeviceInterface().
[0034] The second interface layer includes multiple interface configuration modules, each corresponding to a different interface type. The second interface layer is used by staff to add or delete interfaces of different interface types, making it compatible with multiple interfaces. Furthermore, the configuration of the interfaces can be achieved with only a small amount of code.
[0035] Each interface configuration module mainly includes function call functions, which are used to call the third and fourth interface layers for function configuration. Specifically, the interface configuration module for the USB interface type in the second interface layer is as follows: int USBDvicelnterface:Readma(unsigned int * const data, constunsigned int length, unsigned intOffSet) int ret = NA SUCCESS; ret = usbdevice::GetInstance()->devGetDmaData((char*)data, length); if (ret<0) return NA ERROR READ DMA; NA SUCCESS; As can be seen, the interface configuration module with the current interface type of USB includes the function call function Readma. The interface function is configured downwards through the function call function Readma. Furthermore, different interface configuration modules use a unified function call function to call functions, reducing the amount of code.
[0036] The third interface layer contains the following functional modules that call the function Readma: int DeviceBase:NA ReadDma(const int length, unsigned int * constdata) return DeviceInterface::GetInstance()->ReadDma(data, length); As can be seen, the third interface layer contains the function call function Readma and the current interface function deviceInterface. Since the same function call function is used for function calls in different interface configuration modules in this invention, the current interface function deviceInterface in the third interface layer points the current interface USB to the current interface, so as to achieve different instantiation interfaces by pointing to different interface functions.
[0037] Furthermore, the fourth interface layer contains the following functional implementation module for the function call function Readma: int NA Meas::NA GetMeasDataLength() return NA ReadDma (BULK_BUF_MAX, _measData); As can be seen, the fourth interface layer contains the function call function Readma. Through the function call function Readma, specific implementations of the interface function can be called, so that the specific implementation of the function module can be obtained by calling down through the function call function.
[0038] In summary, the present invention provides a multi-interface compatible configuration method and system based on a layered structure. The method mainly adopts a layered design of the interface configuration structure, with each interface layer having a calling relationship. Different types of interfaces can be activated for configuration by selecting and judging the first interface layer. Furthermore, coders do not need to repeatedly configure specific implementations of functions. When adding or modifying interface configurations, the amount of code that coders need to process is reduced, the configuration process is simplified, and efficiency is improved.
[0039] Example 2 A multi-interface compatible configuration system based on a layered structure, comprising: Interface determination module: When the current interface information of the interface to be instantiated is received, the current interface information is substituted into the first interface layer. The interface function in the first interface layer is selected and judged according to the current interface information, so that the current interface function points to the interface to be instantiated and the corresponding interface activation instruction is generated. Interface Function Confirmation Module: Activates the interface in the second interface layer according to the interface activation instruction, confirms the interface activation, and obtains the function call corresponding to the interface to be instantiated. Interface Function Configuration Module: Based on the current interface function and the corresponding function call function, the module confirms and obtains the specific implementation corresponding to the interface to be instantiated between the third and fourth interface layers with a calling relationship.
[0040] Furthermore, the interface function configuration module also includes the following: Interface Function Confirmation Module: Based on the current interface function, the functional modules in the third interface layer are pointed to the interface to be instantiated. Interface function implementation confirmation module: Matches the corresponding function implementation module in the fourth interface layer based on the function call function; Interface function call module: Based on the function call function in the function implementation module, the module corresponding to the same function call function in the fourth interface layer is called to confirm the specific implementation corresponding to the interface to be instantiated.
[0041] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Based on the technical essence of the present invention, any simple modifications, equivalent substitutions, and improvements made to the above embodiments within the spirit and principles of the present invention shall still fall within the protection scope of the present invention.
Claims
1. A method for multi-interface compatible configuration based on a layered structure, characterized in that, The method specifically includes the following steps: S1: When the current interface information of the interface to be instantiated is received, the current interface information is substituted into the first interface layer. The interface function in the first interface layer is selected and judged according to the current interface information, so that the current interface function points to the interface to be instantiated and the corresponding interface activation instruction is generated. S2: Activate the interface in the second interface layer according to the interface activation instruction, confirm the interface activation and obtain the function call function corresponding to the interface to be instantiated; S3: Based on the current interface function and the corresponding function call function, confirm and obtain the specific instance corresponding to the interface to be instantiated between the third and fourth interface layers with the calling relationship; The third interface layer contains multiple functional modules, each containing an interface function and a function call function; the fourth interface layer contains multiple functional implementation modules, each containing a function call function; the functional modules are used to make unified calls for different interfaces to be instantiated, specifically: by pointing upwards to different interfaces to be instantiated through different pointing interface functions, and simultaneously, by confirming downwards through the function call function to obtain the specific instance of the functional module; The first interface layer contains an interface type determination module, which includes several pointing judgment conditions. Each pointing judgment condition contains a preset interface type and an interface function. The interface function points to the current interface to be instantiated by judging whether the interface type in the current interface information is the preset interface type. The second interface layer includes multiple interface configuration modules, each corresponding to an interface type. The interface configuration module is used to call the function within the interface configuration module to configure the interface.
2. The method of claim 1, wherein, S3 specifically includes the following steps: S30: Based on the current interface function, point the functional module in the third interface layer to the interface to be instantiated; S31: Match the corresponding function implementation module in the fourth interface layer based on the function call function; S32: Based on the function call function in the function implementation module, call the corresponding function module in the fourth interface layer with the same function call function to confirm the specific instance corresponding to the interface to be instantiated.
3. The method of claim 1, wherein, In S1, the interface information includes the interface type, which includes USB and PCIe. When the interface information is substituted into the first interface layer, the interface function in the first interface layer will be selected and judged according to the interface type of the interface to be instantiated, so that the current interface function points to the current interface to be instantiated.
4. The method of claim 3, wherein, In S1, the interface activation instruction is used to represent the pointer result of the interface function in the first interface layer. The pointer result represents the interface to be instantiated at present. Then, the corresponding interface activation instruction is generated according to the interface to be instantiated at present.
5. A multi-interface compatible configuration system based on a layered structure, characterized by, include: Interface determination module: When the current interface information of the interface to be instantiated is received, the current interface information is substituted into the first interface layer. The interface function in the first interface layer is selected and judged according to the current interface information, so that the current interface function points to the interface to be instantiated and the corresponding interface activation instruction is generated. Interface Function Confirmation Module: Activates the interface in the second interface layer according to the interface activation instruction, confirms the interface activation, and obtains the function call corresponding to the interface to be instantiated. Interface function configuration module: Based on the current interface function and the corresponding function call function, it confirms and obtains the specific instance corresponding to the interface to be instantiated between the third and fourth interface layers with the call relationship; The third interface layer contains multiple functional modules, each containing an interface function and a function call function; the fourth interface layer contains multiple functional implementation modules, each containing a function call function; the functional modules are used to make unified calls for different interfaces to be instantiated, specifically: by pointing upwards to different interfaces to be instantiated through different pointing interface functions, and simultaneously, by confirming downwards through the function call function to obtain the specific instance of the functional module; The first interface layer contains an interface type determination module, which includes several pointing judgment conditions. Each pointing judgment condition contains a preset interface type and an interface function. The interface function points to the current interface to be instantiated by judging whether the interface type in the current interface information is the preset interface type. The second interface layer includes multiple interface configuration modules, each corresponding to an interface type. The interface configuration module is used to call the function within the interface configuration module to configure the interface.
6. The multi-interface compatible configuration system based on layered structure according to claim 5, wherein, The interface function configuration module also includes the following: Interface Function Confirmation Module: Based on the current interface function, the functional modules in the third interface layer are pointed to the interface to be instantiated. Interface function implementation confirmation module: Matches the corresponding function implementation module in the fourth interface layer based on the function call function; Interface function call module: Based on the function call function in the function implementation module, the module corresponding to the same function call function in the fourth interface layer is called to confirm the specific instance corresponding to the interface to be instantiated.
Citation Information
Patent Citations
Interface invocation method and device , computer device and storage medium
CN109445845A