Multi-interface compatible configuration method and system based on layered structure
Through the interface configuration method designed by hierarchical structure, different interfaces are activated and functional embodiments are confirmed by utilizing the call relationship between interface layers, which solves the problems of complex and low efficiency of interface compatibility configuration in the prior art, and simplifies configuration and improves The effect of efficiency.
Patent Information
- Application Number
- CN202411164027.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2044-08-23
AI Technical Summary
In the prior art, compatible configurations of multiple interfaces need to be configured separately, resulting in large amount of code and cumbersome configuration processes. Functions need to be reconfigured when adding or modifying interfaces, which affects efficiency.
Using a hierarchical structure design interface configuration method, each interface layer has a call relationship, and different interfaces are activated through the selection of the first interface layer, interface activation instructions are generated, function call functions are confirmed, and the third and fourth interface layers are used. Confirm specific embodiments between the two to reduce duplicate configurations.
It simplifies the configuration process of code personnel, reduces the amount of code, and improves efficiency, making it less code processing when adding or modifying interface configurations, and the configuration process is simple.
Smart Images

Figure CN119127334A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of multi-interface compatibility, and in particular to a method and system for configuring multiple interface compatibility based on a hierarchical structure. Background Art
[0002] During the test process, since different instruments have interfaces of different interface types, it is necessary to meet the compatibility of multiple interfaces to adapt to interfaces of different interface types. Therefore, in order to facilitate the staff to conduct testing and facilitate users to use the same set of software to adapt to multiple instruments, code personnel generally perform compatibility configuration for the interface protocols of multiple interfaces. However, the functional configurations of different interfaces are different. At present, a separate configuration is chosen for each interface, and one interface corresponds to an interface configuration structure. Whenever a new interface is added, the functional configuration of the interface needs to be reconfigured, resulting in a large amount of code that the code personnel need to process and a cumbersome configuration process. Summary of the invention
[0003] The purpose of the present invention is to provide a method and system for configuring multiple interface compatibility based on a hierarchical structure. The method mainly adopts a hierarchical design of the interface configuration structure. There is a calling relationship between each interface layer. Different types of interfaces can be activated for configuration through selection and judgment in the first interface layer. In addition, code personnel do not need to repeatedly configure the specific implementation methods of the functions. When adding or modifying the interface configuration, the amount of code that code personnel need to process can be reduced, the configuration process is simple, and efficiency is improved.
[0004] In order to solve the above technical problems, the present invention adopts the following solutions: A method for configuring multiple interface compatibility based on a hierarchical structure, the method specifically comprising the following steps: S1: when receiving the current interface information of the current interface to be instantiated, the current interface information is substituted into the first interface layer, and 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 current interface to be instantiated, and a 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 current interface to be instantiated; S3: According to the current interface function and the corresponding function calling function, confirm and obtain the specific implementation corresponding to the current interface to be instantiated between the third interface layer and the fourth interface layer having a calling relationship.
[0005] Furthermore, S3 specifically includes the following steps: S30: Pointing the functional module in the third interface layer to the current interface to be instantiated according to the current interface function; S31: matching the corresponding function implementation module in the fourth interface layer according to the function call function; S32: According to the function calling function in the function implementation module, the function module corresponding to the same function calling function is called in the fourth interface layer to confirm the specific implementation method corresponding to the current interface to be instantiated.
[0006] Further, the third interface layer includes a plurality of function modules, each of which includes an interface function and a function call function; and the fourth interface layer includes a plurality of function implementation modules, each of which includes a function call function; The functional module is used to make unified calls to different interfaces to be instantiated, specifically: pointing upward to different interfaces to be instantiated through different pointing interface functions, and at the same time, confirming downward to obtain a specific implementation of the functional module through a function calling function.
[0007] Furthermore, in S1, the interface information includes an interface type, and the interface types include 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 current 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 a number of pointing judgment conditions, each pointing judgment condition includes a preset interface type and an interface function, and determines whether 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.
[0009] Further, in S1, the interface activation instruction is used to represent the pointing result of the interface function in the first interface layer, and the pointing result represents the current interface to be instantiated, and the corresponding interface activation instruction is generated according to the current interface to be instantiated.
[0010] Furthermore, the second interface layer includes a plurality of interface configuration modules, the interface configuration modules correspond to the interface types one by one, and the interface configuration modules are used to call downward according to the function call function in the interface configuration module to implement the configuration of the interface.
[0011] A multi-interface compatible configuration system based on a hierarchical structure, comprising: Interface determination module: when receiving the current interface information of the current interface to be instantiated, the current interface information is substituted into the first interface layer, and the interface function in the first interface layer is selected and determined according to the current interface information, so that the current interface function points to the current interface to be instantiated, and a corresponding interface activation instruction is generated; Interface function confirmation module: performs interface activation in the second interface layer according to the interface activation instruction, and obtains the function call function corresponding to the current interface to be instantiated through interface activation confirmation; Interface function configuration module: confirm and obtain the specific implementation corresponding to the current interface to be instantiated between the third interface layer and the fourth interface layer having a calling relationship according to the current interface function and the corresponding function calling function.
[0012] Furthermore, the interface function configuration module also includes the following: Interface function confirmation module: points the function module in the third interface layer to the current interface to be instantiated according to the current interface function; Interface function implementation confirmation module: matches the corresponding function implementation module in the fourth interface layer according to the function call function; Interface function calling module: according to the function calling function in the function implementation module, the function module corresponding to the same function calling function is called in the fourth interface layer to confirm the specific implementation method corresponding to the current interface to be instantiated.
[0013] Beneficial effects of the present invention: The present invention provides a method and system for configuring multiple interface compatibility based on a hierarchical structure. The method mainly adopts a hierarchical design of the interface configuration structure. There is a calling relationship between each interface layer. Different types of interfaces can be activated for configuration through selection and judgment at the first interface layer. In addition, code personnel do not need to repeatedly configure the specific implementation methods of the functions. When adding or modifying the interface configuration, the amount of code that code personnel need to process can be reduced, the configuration process is simple, and efficiency is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 The figure is a flowchart of a method for configuring compatibility of multiple interfaces based on a hierarchical structure in Embodiment 1 of the present invention.
[0015] Figure 2 This is a schematic diagram of the interface layer calling relationship in Example 1 of the present invention.
[0016] Figure 3 This is a schematic diagram of the interface configuration structure in Example 1 of the present invention. DETAILED DESCRIPTION
[0017] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. The following description of at least one exemplary embodiment is actually only illustrative and is by no means intended to limit the present invention and its application or use. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0018] The relative arrangement of components and steps, the numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless specifically stated otherwise.
[0019] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0020] Additionally, descriptions of well-known structures, functions, and configurations may be omitted for clarity and conciseness.One of ordinary skill in the art will recognize that various changes and modifications may be made to the examples described herein without departing from the spirit and scope of the present disclosure.
[0021] Technologies, methods, and apparatus known to ordinary technicians in the relevant field may not be discussed in detail, but where appropriate, such technologies, methods, and apparatus should be considered part of the authorization specification.
[0022] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limiting. Therefore, other examples of the exemplary embodiments may have different values.
[0023] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments: Example 1 like Figure 1 As shown, a method for configuring multiple interface compatibility based on a hierarchical structure, the method specifically includes the following steps: S1: when receiving the current interface information of the current interface to be instantiated, the current interface information is substituted into the first interface layer, and 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 current interface to be instantiated, and a 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 current interface to be instantiated; S3: According to the current interface function and the corresponding function calling function, confirm and obtain the specific implementation corresponding to the current interface to be instantiated between the third interface layer and the fourth interface layer having a calling relationship.
[0024] Preferably, S3 specifically includes the following steps: S30: Pointing the functional module in the third interface layer to the current interface to be instantiated according to the current interface function; S31: matching the corresponding function implementation module in the fourth interface layer according to the function call function; S32: According to the function calling function in the function implementation module, the function module corresponding to the same function calling function is called in the fourth interface layer to confirm the specific implementation method corresponding to the current interface to be instantiated.
[0025] Preferably, the third interface layer includes a plurality of function modules, each of which includes an interface function and a function call function; and the fourth interface layer includes a plurality of function implementation modules, each of which includes a function call function; The functional module is used to make unified calls to different interfaces to be instantiated, specifically: pointing upward to different interfaces to be instantiated through different pointing interface functions, and at the same time, confirming downward to obtain a specific implementation of the functional module through a function calling function.
[0026] Preferably, in S1, the interface information includes an interface type, and the interface types include 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 current 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, and the interface type determination module includes a plurality of pointing judgment conditions, each pointing judgment condition includes a preset interface type and an interface function, and determines whether 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.
[0028] Preferably, in S1, the interface activation instruction is used to represent the pointing result of the interface function in the first interface layer, and the pointing result represents the current interface to be instantiated, and the corresponding interface activation instruction is generated according to the current interface to be instantiated.
[0029] Preferably, the second interface layer includes a plurality of interface configuration modules, the interface configuration modules correspond to the interface types one by one, and the interface configuration modules are used to call downwards according to the function call function in the interface configuration module to implement the configuration of the interface.
[0030] Based on the above principles, the present invention is further described: In order to reduce the amount of code required by code personnel for multiple interfaces, the present invention selects a hierarchical interface configuration structure, which includes a first interface layer, a second interface layer, a third interface layer, and a fourth interface layer, so that the first interface layer, the second interface layer, the third interface layer, and the fourth interface layer have a calling relationship, and the calling relationship is: 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. Then, the function of the currently connected interface can be called and obtained on the fourth interface layer. Specific embodiments, such as Figure 2 As shown, the first interface layer points to the second interface layer through the interface function, which is used to confirm the interface type of the current interface; the second interface layer can confirm the corresponding function calling function according to the current interface function, and the function calling function is used to call to obtain a specific implementation of the function; the third interface layer calls the first interface layer through the current interface function, and confirms the corresponding function calling function in the third interface layer according to the current interface function; the fourth interface layer calls the third interface layer through the function calling function, at this time, the specific implementation of the interface function can be called on the fourth interface layer according to the function calling function.
[0031] In this embodiment, based on the above 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 be used to select and activate interface configuration module 1 or interface configuration module 2, so that the interface function points to the interface of the corresponding interface type. At this time, if interface configuration module 1 is selected for activation, the function call function corresponding to the current interface to be instantiated can be confirmed in interface configuration module 1 in the second interface layer. An interface configuration module is used to represent the interface configuration corresponding to an interface type, and each interface can be configured with a variety of different functions. Each interface configuration module can correspond to multiple function modules, which is represented by a plurality of different function call functions in an interface configuration module, and a function call function corresponds to a function module. In the third interface layer, the function call function and the interface function can be used to confirm the corresponding interface configuration module 1. If there are function modules 1 and function modules 2, then the interface function in the interface configuration module 1 is the same interface function as the interface functions in the function modules 1 and function modules 2, and the function calling function in the interface configuration module 1 corresponds one to one to the function modules 1 and function modules 2 respectively, then in the fourth interface layer, a function implementation module can be obtained by confirming the function calling functions corresponding to different function modules, and a function implementation module is used to represent a specific implementation example of a function corresponding to a function, then each function module corresponds to a function implementation module, and a unified function calling function is used for interfaces of multiple interface types, so that the interface function is called for a specific implementation example through a unified function calling function, so as to realize the specific implementation example of the function module by calling downward through the function calling function.
[0032] If a new interface needs to be connected, it is only necessary to add the interface type in the first interface layer and add the basic settings of the interface in the second interface layer, that is, to add an interface configuration module. The interface configuration module can automatically call functions from the third interface layer and the fourth interface layer through the function call function, and there is no need for the staff to manually configure the functions of the interface. It is equivalent to extracting the function configuration file in the interface configuration structure corresponding to each interface in the prior art, and designing the interface activation file and function configuration file in layers, and calling them through a unified calling function.
[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(); It can be seen that the current first interface layer includes an interface type determination module, and the current interface type determination module includes two pointing judgment conditions. The two pointing judgment conditions both contain a preset interface type and an interface function. The preset interface types are divided into USB and VISA. The interface function is deviceInterface. If the currently connected interface is USB, the current interface function deviceInterface is pointed to USB according to the pointing judgment condition, that is, _deviceInterface =new USBDeviceInterface().
[0034] The second interface layer includes multiple interface configuration modules, each interface configuration module corresponds to a different interface type. The second interface layer is used by staff to add or delete interfaces of different interface types, so that it can be compatible with multiple interfaces, and only a small amount of code is required to configure the interface.
[0035] Each interface configuration module mainly includes a function call function, which is used to call the third interface layer and the fourth interface layer for function configuration. Specifically, the interface configuration module part of the second interface layer with the interface type of USB 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; return NA SUCCESS; It can be seen that the interface configuration module whose current interface type is USB includes a function call function Readma, through which the interface function configuration is performed downward, and a unified function call function is used in different interface configuration modules to perform function calls, thereby reducing the amount of code.
[0036] The function modules in the third interface layer that contain the function call function Readma are as follows: int DeviceBase:NA ReadDma(const int length, unsigned int * constdata) return DeviceInterface::GetInstance()->ReadDma(data, length); It can be seen that the third interface layer includes a function call function Readma and a current interface function deviceInterface. Since, in the present invention, a unified function call function is used in different interface configuration modules for function calls, the current function module in the third interface layer is pointed to the current interface USB through the current interface function deviceInterface in the third interface layer, thereby realizing different interfaces to be instantiated through different pointed interface functions.
[0037] Furthermore, the function implementation module including the function call function Readma in the fourth interface layer is as follows: int NA Meas::NA GetMeasDataLength() return NA ReadDma (BULK_BUF_MAX, _measData); It can be seen that the fourth interface layer includes a function calling function Readma, through which the interface function can be called for a specific implementation example, thereby realizing a specific implementation example of the function module by calling down through the function calling function.
[0038] In summary, the present invention provides a method and system for configuring multiple interface compatibility based on a hierarchical structure. The method mainly adopts a hierarchical design of the interface configuration structure. There is a calling relationship between each interface layer. Different types of interfaces can be activated for configuration through selection and judgment in the first interface layer. In addition, code personnel do not need to repeatedly configure the specific implementation methods of the functions. When adding or modifying the interface configuration, the amount of code that code personnel need to process is less, the configuration process is simple, and efficiency is improved.
[0039] Example 2 A multi-interface compatible configuration system based on a hierarchical structure, comprising: Interface determination module: when receiving the current interface information of the current interface to be instantiated, the current interface information is substituted into the first interface layer, and the interface function in the first interface layer is selected and determined according to the current interface information, so that the current interface function points to the current interface to be instantiated, and a corresponding interface activation instruction is generated; Interface function confirmation module: performs interface activation in the second interface layer according to the interface activation instruction, and obtains the function call function corresponding to the current interface to be instantiated through interface activation confirmation; Interface function configuration module: confirm and obtain the specific implementation corresponding to the current interface to be instantiated between the third interface layer and the fourth interface layer having a calling relationship according to the current interface function and the corresponding function calling function.
[0040] Furthermore, the interface function configuration module also includes the following: Interface function confirmation module: points the function module in the third interface layer to the current interface to be instantiated according to the current interface function; Interface function implementation confirmation module: matches the corresponding function implementation module in the fourth interface layer according to the function call function; Interface function calling module: according to the function calling function in the function implementation module, the function module corresponding to the same function calling function is called in the fourth interface layer to confirm the specific implementation method corresponding to the current interface to be instantiated.
[0041] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. According to the technical essence of the present invention, within the spirit and principles of the present invention, any simple modification, equivalent replacement and improvement made to the above embodiment still falls within the protection scope of the technical solution of the present invention.
Claims
1. A method for configuring multiple interface compatibility based on a hierarchical structure, characterized in that: The method specifically comprises the following steps: S1: when receiving the current interface information of the current interface to be instantiated, the current interface information is substituted into the first interface layer, and 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 current interface to be instantiated, and a 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 current interface to be instantiated; S3: According to the current interface function and the corresponding function calling function, confirm and obtain the specific implementation corresponding to the current interface to be instantiated between the third interface layer and the fourth interface layer having a calling relationship.
2. The method for configuring multiple interface compatibility based on a hierarchical structure according to claim 1, characterized in that: The S3 specifically includes the following steps: S30: Pointing the functional module in the third interface layer to the current interface to be instantiated according to the current interface function; S31: matching the corresponding function implementation module in the fourth interface layer according to the function call function; S32: According to the function calling function in the function implementation module, the function module corresponding to the same function calling function is called in the fourth interface layer to confirm the specific implementation method corresponding to the current interface to be instantiated.
3. The method for configuring multiple interface compatibility based on a hierarchical structure according to claim 1, characterized in that: The third interface layer includes a plurality of function modules, each of which includes an interface function and a function call function; and the fourth interface layer includes a plurality of function implementation modules, each of which includes a function call function; The functional module is used to make unified calls to different interfaces to be instantiated, specifically: pointing upward to different interfaces to be instantiated through different pointing interface functions, and at the same time, confirming downward to obtain a specific implementation of the functional module through a function calling function.
4. The method for configuring multiple interface compatibility based on a hierarchical structure according to claim 1, characterized in that: 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 current interface to be instantiated, so that the current interface function points to the current interface to be instantiated.
5. The method for configuring multiple interface compatibility based on a hierarchical structure according to claim 4, characterized in that: The first interface layer includes an interface type determination module, which includes several pointing determination conditions. Each pointing 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.
6. The method for configuring multiple interface compatibility based on a hierarchical structure according to claim 4, characterized in that: In S1, the interface activation instruction is used to indicate the pointing result of the interface function in the first interface layer, and the pointing result indicates the current interface to be instantiated, and then a corresponding interface activation instruction is generated according to the current interface to be instantiated.
7. The method for configuring multiple interface compatibility based on a hierarchical structure according to claim 4, characterized in that: The second interface layer includes a plurality of interface configuration modules, each of which corresponds to an interface type in a one-to-one manner. The interface configuration module is used to call downward according to a function call function in the interface configuration module to implement configuration of the interface.
8. A multi-interface compatible configuration system based on a hierarchical structure, characterized in that: include: Interface determination module: when receiving the current interface information of the current interface to be instantiated, the current interface information is substituted into the first interface layer, and the interface function in the first interface layer is selected and determined according to the current interface information, so that the current interface function points to the current interface to be instantiated, and a corresponding interface activation instruction is generated; Interface function confirmation module: performs interface activation in the second interface layer according to the interface activation instruction, and obtains the function call function corresponding to the current interface to be instantiated through interface activation confirmation; Interface function configuration module: confirm and obtain the specific implementation corresponding to the current interface to be instantiated between the third interface layer and the fourth interface layer having a calling relationship according to the current interface function and the corresponding function calling function.
9. The hierarchical structure-based multi-interface compatible configuration system according to claim 8, characterized in that: The interface function configuration module also includes the following: Interface function confirmation module: points the function module in the third interface layer to the current interface to be instantiated according to the current interface function; Interface function implementation confirmation module: matches the corresponding function implementation module in the fourth interface layer according to the function call function; Interface function calling module: according to the function calling function in the function implementation module, the function module corresponding to the same function calling function is called in the fourth interface layer to confirm the specific implementation method corresponding to the current interface to be instantiated.
Citation Information
Patent Citations
Interface conversion method and device
CN103559023A
Interface calling method, device and computer-readable storage medium
CN109254808A
Interface invocation method and device , computer device and storage medium
CN109445845A
Intermediate interface calling method, device and system, storage medium and electronic equipment
CN113515389A
Service interface registration method and device, service interface use method and device, equipment and medium
CN116795336A
