A method and device for automatically generating switch driver code

By defining the switch driver model and realizing graphical editing and automatic code generation, it solves the problem in the existing technology that the core code of the channel topology connection relationship needs to be manually edited, reduces development difficulty and maintenance costs, and improves development efficiency and code management. Ease of use.

CN111984255BActive Publication Date: 2024-09-27CHINA ELECTRONIS TECH INSTR CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202010833036.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-18
Publication Date
2024-09-27
Estimated Expiration
2040-08-18

AI Technical Summary

Technical Problem

Existing switch driver development tools cannot automatically generate the core code of channel topology connection relationships, resulting in increased development difficulty, complexity, and maintenance costs, and requiring developers to be familiar with different operating systems and programming languages.

Method used

Define switch driver models and implement graphical editing functions. Through unified management of models, code templates, and conversion rules, switch driver codes are automatically generated, reducing development difficulty and maintenance costs.

Benefits of technology

It realizes the automatic generation of switch driver code, reduces development difficulty and maintenance costs, improves development efficiency and ease of code management, and supports the definition and expansion of code templates and conversion rules for different types and operating systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111984255B
    Figure CN111984255B
Patent Text Reader

Abstract

The present disclosure provides a method and device for automatically generating switch driver code, including: obtaining input information with channel topological connection relationship, establishing and / or editing a switch driver model according to the input information, and setting model information of the switch driver model; establishing the topological connection relationship of each component in the model information in sequence according to the input information, and saving the switch driver model with the established topological connection relationship; calling code templates and conversion rules according to the input information and the switch driver model with the completed topological connection relationship, and generating the switch driver code of the input information; realizing unified editing and management of switch driver code templates and conversion rules, supporting the definition and extension of different types of switch driver code templates and conversion rules, and improving the sharing and reuse of switch driver development experience and knowledge.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method and device for automatically generating switch driver code. Background Art

[0002] The switch is the hub of signal transmission and distribution in the automatic test system. The use of switches can make full use of test resources, reduce the workload of switching various instruments, extend the service life of instruments, and improve test efficiency. Because it can improve the performance and flexibility of automatic testing, the use of switches in automatic test systems is becoming more and more common. For the control of switches, it is usually implemented by system integration developers calling the driver provided by the switch manufacturer. At present, there are many types of switch drivers, including VISA, IVI-C, IVI-COM and IVI-.NET. For different operating systems and different types of switch drivers, developers are often required to use different development tools for development. At present, although commercial switch driver development tools can automatically generate part of the code for a certain specific development language, the core code such as building the channel topology structure must be manually added by the developer. This way of developing switch drivers using commercial development tools requires, on the one hand, that the driver developers must be familiar with different operating systems, development tools and programming languages, and write a lot of code for different operating systems and different types of switch drivers; on the other hand, the developed driver code must also be managed and maintained using different tools in different operating systems. Therefore, this way of developing switch drivers not only greatly increases the development workload and development difficulty of developers, but also increases the management and maintenance costs of the code.

[0003] Currently, there are two main commercial driver switch tools: 1) NI's "IVIInstrument Driver Wizard" tool under CVI, which uses the wizard to fill in the instrument's bus type, manufacturer and other information in turn, and automatically generates a driver code framework; 2) Nimbus's driver development tool, which can be used to generate IVI-C and IVI-COM switch driver codes, supports manual switch connection and disconnection program-controlled command editing, and automatically generates a driver code framework. Both of these commercial tools use a wizard method and can only automatically generate code files in a specific language based on user input information. The core code of the channel topology connection relationship has to be manually edited by the user, and does not support the modification and expansion of code templates and conversion rules for different languages ​​and operating systems.

[0004] Corresponding to the above two methods of using wizards to realize switch driver code generation, since they only support the generation of partial codes in one or two programming languages, and neither can provide automatic generation of core codes such as channel topology connection relationships, this method of using commercial driver development tools to develop switch drivers often leads to increased development difficulty, complexity and workload, and also increases the cost of later code maintenance. Summary of the invention

[0005] In order to solve the above technical problems, the present disclosure provides a method and device for automatically generating switch driver code. First, a switch driver model is defined, and a graphical editing function of the model is implemented. Secondly, an existing switch driver code template and conversion rule are created or selected, and the information in the model is used to generate a corresponding code module according to the conversion rule, and the corresponding content in the code template is replaced to realize the automatic generation of the switch model to the switch driver code. Finally, unified management and maintenance of the switch driver code template and conversion rules are provided, and the maintenance at the code layer is transformed into the maintenance of the switch driver model, code template and conversion rules. The development method of automatic generation from model to code proposed in the present disclosure, on the one hand, reduces the difficulty of driver development and improves development efficiency, and on the other hand, realizes centralized management of model files, code templates and conversion rules, which is conducive to the management and maintenance of driver code.

[0006] In a first aspect, the present disclosure provides a method for automatically generating switch driver code, comprising:

[0007] Obtain input information with channel topology connection relationship, establish and / or edit a switch driver model according to the input information, and set model information of the switch driver model;

[0008] Establishing the topological connection relationship of each component in the model information in sequence according to the input information, and saving the switch driver model with the established topological connection relationship;

[0009] The switch driver code of the input information is generated by calling the code template and the conversion rule according to the input information and the switch driver model that completes the topological connection relationship.

[0010] In a second aspect, the present disclosure provides a device for automatically generating switch driver code, comprising:

[0011] The switch driver model editing module is configured to: obtain input information with channel topological connection relationship, establish and / or edit the switch driver model according to the input information, and set the model information of the switch driver model; establish the topological connection relationship of each component in the model information in turn according to the input information, and save the switch driver model with the established topological connection relationship;

[0012] The switch driver code generation module is configured to call the code template and conversion rules according to the input information and the switch driver model that completes the topological connection relationship, and generate the code of the input information.

[0013] In a third aspect, the present disclosure provides a computer-readable storage medium for storing computer instructions, which, when executed by a processor, completes the method for automatically generating switch driver program code as described in the first aspect.

[0014] In a fourth aspect, the present disclosure further provides an electronic device, comprising a memory and a processor, and computer instructions stored in the memory and executed on the processor, wherein when the computer instructions are executed by the processor, the method for automatically generating switch driver program code as described in the first aspect is completed.

[0015] Compared with the prior art, the present invention has the following beneficial effects:

[0016] 1. The present invention proposes and defines a switch driver model consisting of a switch channel name, a physical topology structure, and a control method, designs a graphical way to edit the switch driver model, and can save the model as a switch driver model file; solves the problem that the core code of the channel topology connection relationship has to be manually edited by the user, and does not support the modification and extension of code templates and conversion rules of different languages ​​and operating systems, realizes the creation, editing, saving and classification management of switch driver code templates and conversion rules, and realizes the automatic generation of switch driver model to driver code; reduces the development difficulty of the switch driver model, improves the ease of use and efficiency of model design, realizes the unified editing and management of switch driver code templates and conversion rules, supports the definition and extension of different types of switch driver code templates and conversion rules, and improves the sharing and reuse of switch driver development experience and knowledge.

[0017] 2. The present invention generates switch driver code for input information by calling code templates and conversion rules according to the switch driver model that completes the topological connection relationship. This solves the problem that driver developers must be familiar with different operating systems, development tools and programming languages, and need to write a large amount of code for different operating systems and different types of switch drivers. It realizes the automatic generation of switch driver model to code, so that developers do not need to worry about the implementation method of switch driver under any type. They only need to graphically edit the switch channel list and topological structure for different switches, which reduces the requirements for developers and improves the development efficiency of switch drivers.

[0018] 3. The present invention establishes and / or edits a switch driver model according to input information, and sets model information of the switch driver model; establishes the topological connection relationship of each component in the model information in sequence according to the input information, and saves the switch driver model with the established topological connection relationship, thereby solving the problem that the developed driver code must also be managed and maintained using different tools in different operating systems, and realizes centralized management of the switch driver model, code templates and conversion rules, which is beneficial to the management and maintenance of the driver code. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The drawings in the specification, which constitute a part of the present application, are used to provide further understanding of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute improper limitations on the present application.

[0020] Figure 1 It is a structural schematic diagram of the switch driver program code automatic generation device disclosed in the present invention;

[0021] Figure 2 A flowchart of the automatic generation device of switch driver code disclosed in the present invention;

[0022] Figure 3 It is a structural schematic diagram of the method for automatically generating switch driver code disclosed in the present invention;

[0023] Figure 4 A workflow diagram of the code template and conversion rule management module disclosed in the present invention;

[0024] Figure 5 The flowchart of the switch driver code generation module disclosed in the present invention. DETAILED DESCRIPTION

[0025] The present disclosure is further described below in conjunction with the accompanying drawings and embodiments.

[0026] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present application belongs.

[0027] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.

[0028] Example 1

[0029] like Figure 1 As shown, a method for automatically generating switch driver code includes:

[0030] Obtain input information with channel topology connection relationship, establish and / or edit a switch driver model according to the input information, and set model information of the switch driver model;

[0031] Establishing the topological connection relationship of each component in the model information in sequence according to the input information, and saving the switch driver model with the established topological connection relationship;

[0032] The switch driver code of the input information is generated by calling the code template and the conversion rule according to the input information and the switch driver model that completes the topological connection relationship.

[0033] Furthermore, the step of obtaining input information with channel topological connection relationships, establishing and / or editing a switch driver model according to the input information, and setting the model information of the switch driver model specifically includes: obtaining switch manufacturer, switch model, channel list, switch drive type and channel control mode information as well as the channel topological connection relationship between each piece of information; editing the switch manufacturer, switch model, channel list, switch drive type and channel control mode information in the model, and establishing the switch channel topological connection relationship of each piece of information in turn.

[0034] Furthermore, the topological connection relationship of each component in the model information is established in sequence according to the input information, and the switch driver model with the established topological connection relationship is stored specifically:

[0035] Establish the topological connection relationship of each component in the model information in sequence according to the input information;

[0036] Determine whether the establishment of all channel topology connection relationships is completed;

[0037] If it is not completed, the topological connection relationship of each component in the model information is established in sequence according to the input information; otherwise, the switch driver model with the topological connection relationship established is saved.

[0038] Further, according to the input information and the switch driver model that completes the topological connection relationship, the code template and the conversion rule are called to generate the code of the input information:

[0039] According to the target type in the switch driver model, a code template and a conversion rule corresponding to the target type are obtained;

[0040] Fill the switch drive name, type and channel name list information in the model information directly into the code template;

[0041] According to the conversion rules, the switch channel topology connection relationship is converted into the switch channel topology structure construction code, the control mode is converted into the instrument connection and disconnection control code, and the filling position corresponding to the code to be filled in the code template is obtained;

[0042] Add the generated code to the corresponding position of the code template and save it as the switch driver code.

[0043] Furthermore, the generation step of the code template and conversion rule is specifically as follows: establishing and / or editing the code template and conversion rule through the code template and conversion rule management module, editing the current code template and conversion rule, until the code template and conversion rule are edited; wherein the code template includes a basic framework of the driver code corresponding to the target type switch, which is used to record the code template manually edited according to the target type; the code conversion rule defines the channel topology connection relationship and the conversion of the control relationship to the code, which is used to implement the control code for creating the channel topology structure and disconnecting the switch connection;

[0044] Specifically, the steps of establishing and / or editing code templates and conversion rules through the code template and conversion rule management module, editing the current code template and conversion rules, and completing the editing of the code template and conversion rules include: determining the target software platform according to actual needs, querying whether there are code templates and code conversion rules of the target software platform in the driving signal code template and conversion rule management module, and if so, selecting the target software platform to obtain the code template and code conversion rules of the target software platform, and converting the switch driver model that completes the topological connection relationship into the switch driver code according to the code template and code conversion rules of the target software platform.

[0045] Example 2

[0046] A switch driver program code automatic generation device, comprising:

[0047] The switch driver model editing module is configured to: obtain input information with channel topological connection relationship, establish and / or edit the switch driver model according to the input information, and set the model information of the switch driver model; establish the topological connection relationship of each component in the model information in turn according to the input information, and save the switch driver model with the established topological connection relationship;

[0048] The switch driver code generation module is configured to call the code template and conversion rules according to the input information and the switch driver model that completes the topological connection relationship, and generate the code of the input information.

[0049] Furthermore, the specific configuration modes of the switch driver model editing module and the switch driver code generating module correspond to the specific steps of the switch driver code automatic generation method described in the above embodiment.

[0050] like Figure 1 As shown. The switch driver model editing module is used to create or open an existing switch driver model file, and also supports graphical editing of the switch driver model. The code template and conversion rule management module is used to create, edit, modify and save code templates and conversion rules; the switch driver model file is an XML type file, containing information such as the switch manufacturer, switch model, channel list, switch driver type, channel topology and channel control method; the switch driver code generation module automatically selects the corresponding code template and conversion rule based on the switch driver type, operating system, target programming language and other information, and converts the information in the model into the target programming language code, and finally inserts the target programming language code into the code template to form a driver code file.

[0051] The three-part collaborative relationship is as follows Figure 2 As shown: First, run the switch driver model editing module to graphically edit the switch driver model information; second, run the switch driver code generation module, call or create code templates and conversion rules, and generate code in the target programming language; finally, check whether the generated code meets the requirements. If not, run the code template and conversion rule management module to modify the code template and conversion rules, and then run the switch driver code generation module to generate code, until the generated driver code meets the requirements.

[0052] The switch driver model editing module creates or opens an existing switch driver model, edits the switch manufacturer, switch model, channel list, switch drive type, channel control method and other information in the model, and establishes the switch channel topology connection relationship in sequence until all channel topology connection management is established, and saves the model information as a switch driver model file. The workflow is as follows: Figure 3 shown.

[0053] The code template and conversion rule management module creates or opens existing code templates and conversion rules, and edits the current code templates and conversion rules until the code templates and conversion rules are edited. The workflow is as follows: Figure 4 The code template includes the basic framework of the driver code corresponding to the target type switch, which is used to record the code template manually edited according to the target type; the code conversion rule defines the channel topology connection relationship and the conversion of the control relationship to the code, which is used to implement the control code for channel topology structure creation and switch connection disconnection.

[0054] The switch driver code generation module first obtains the code template and conversion rules corresponding to the target type according to the target type in the switch driver model; secondly, it directly fills the switch driver name, type, channel name list and other information in the model into the code template; again, according to the conversion rules, it generates the switch channel topology structure construction code from the switch channel topology connection relationship, generates the instrument connection and disconnection control code from the control method, and obtains the filling position corresponding to the code to be filled in the code template; finally, it adds the generated code to the corresponding position of the code template and saves it as the switch driver code file. The specific workflow is as follows: Figure 5 shown.

[0055] This patent disclosure first proposes and defines a switch driver model, and implements the graphical editing function of the model, reducing the difficulty of developing the switch driver model and improving the ease of use and efficiency of model design. Secondly, it realizes the automatic generation of switch model to switch driver code, so that developers do not need to worry about the switch driver implementation methods under different operating systems and different programming languages. They only need to graphically edit the switch channel list and topology structure for different switches, which reduces the requirements for developers and improves the development efficiency of the switch driver. Finally, it realizes the unified editing and management of switch driver model files, code templates and conversion rules, supports the expansion of switch driver code templates and conversion rules for new programming languages, and reduces the maintenance and management costs of switch driver code.

[0056] In other embodiments, the present disclosure further provides:

[0057] A computer-readable storage medium is used to store computer instructions. When the computer instructions are executed by a processor, the method for automatically generating switch driver program code as described in the above embodiment is completed.

[0058] An electronic device includes a memory and a processor, and computer instructions stored in the memory and executed on the processor. When the computer instructions are executed by the processor, the method for automatically generating switch driver code as described in the above embodiment is completed.

[0059] Although the above describes the specific implementation methods of the present disclosure in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present disclosure. Technical personnel in the relevant field should understand that on the basis of the technical solution of the present disclosure, various modifications or variations that can be made by those skilled in the art without creative work are still within the scope of protection of the present disclosure.

Claims

1. A method for automatically generating switch driver code, characterized in that: include: Obtain input information with channel topology connection relationship, establish and / or edit a switch driver model according to the input information, and set model information of the switch driver model; Establishing the topological connection relationship of each component in the model information in sequence according to the input information, and saving the switch driver model with the established topological connection relationship; The switch driver code for the input information is generated according to the code template and the conversion rule of the switch driver model that completes the topological connection relationship; The step of obtaining input information with a channel topology connection relationship, establishing and / or editing a switch driver model according to the input information, and setting model information of the switch driver model specifically includes: Obtain switch manufacturer, switch model, channel list, switch drive type and channel control mode information as well as the channel topology connection relationship between each piece of information; Edit the switch manufacturer, switch model, channel list, switch drive type and channel control mode information in the model, and establish the switch channel topology connection relationship of each information in turn.

2. The method for automatically generating switch driver code according to claim 1, characterized in that: The topological connection relationship of each component in the model information is established in sequence according to the input information, and the switch driver model with the established topological connection relationship is stored as follows: Establish the topological connection relationship of each component in the model information in sequence according to the input information; Determine whether the establishment of all channel topology connection relationships is completed; If it is not completed, the topological connection relationship of each component in the model information is established in sequence according to the input information; otherwise, the switch driver model with the topological connection relationship established is saved.

3. The method for automatically generating switch driver code according to claim 1, characterized in that: The code template and conversion rules are called according to the input information and the switch driver model that completes the topological connection relationship. The code that generates the input information is specifically: According to the target type in the switch driver model, a code template and a conversion rule corresponding to the target type are obtained; Fill the model information into the code template; According to the conversion rules, the switch channel topology connection relationship is converted into the switch channel topology structure construction code, the control mode is converted into the instrument connection and disconnection control code, and the filling position corresponding to the code to be filled in the code template is obtained; Add the generated code to the corresponding position of the code template and save it as the switch driver code.

4. The method for automatically generating switch driver code according to claim 3, characterized in that: The model information includes switch drive name, type and channel name list information.

5. The method for automatically generating switch driver code according to claim 1, characterized in that: The steps for generating the code template and conversion rules are specifically as follows: The code template and conversion rule management module is used to create and / or edit the code template and conversion rule, and the current code template and conversion rule are edited until the code template and conversion rule are edited.

6. The method for automatically generating switch driver code according to claim 5, characterized in that: The code template includes a basic framework of the driver code corresponding to the target type in the switch driver model, and is used to record the code template manually edited according to the target type; The code conversion rules are used to define the conversion of channel topology connection relations and control relations into codes, and implement control codes for channel topology creation and switch connection disconnection.

7. A device for automatically generating switch driver code, characterized in that: include: The switch driver model editing module is configured to: obtain input information with channel topological connection relationship, establish and / or edit the switch driver model according to the input information, and set the model information of the switch driver model; establish the topological connection relationship of each component in the model information in turn according to the input information, and save the switch driver model with the established topological connection relationship; The switch driver code generation module is configured to: call the code template and the conversion rule according to the input information and the switch driver model that completes the topological connection relationship, and generate the code of the input information; The step of obtaining input information with a channel topology connection relationship, establishing and / or editing a switch driver model according to the input information, and setting model information of the switch driver model specifically includes: Obtain switch manufacturer, switch model, channel list, switch drive type and channel control mode information as well as the channel topology connection relationship between each piece of information; Edit the switch manufacturer, switch model, channel list, switch drive type and channel control mode information in the model, and establish the switch channel topology connection relationship of each information in turn.

8. A computer-readable storage medium for storing computer instructions, characterized in that: When the computer instructions are executed by the processor, the method for automatically generating switch driver program code according to any one of claims 1 to 6 is completed.

9. An electronic device, characterized in that: The invention comprises a memory and a processor and computer instructions stored in the memory and executed on the processor. When the computer instructions are executed by the processor, the method for automatically generating the switch driver program code according to any one of claims 1 to 6 is completed.

Citation Information

Patent Citations

  • Method for rapid implementation of matrix switch graphical control system

    CN103294532A

  • Control method and system for multiple switches in automatic testing system

    CN103312424A

  • Method for generating MapReduce codes based on MDE (Model-Driven Engineering) model transformation

    CN104679511A

  • Automatic generation method and device for signal driving program code

    CN108829395A

  • Language and mechanism for modeling and exporting storage platform topologies, attributes, and behaviors

    US10693962B1