Method for automatically generating software work product by defining protocol data
By formalizing the communication protocol and automatically generating source code and interface, the problem of low efficiency in writing communication protocol documents is solved, and efficient R&D testing and software documentation standardization are achieved.
Patent Information
- Application Number
- CN202510798355.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-16
- Publication Date
- 2025-09-19
AI Technical Summary
In the existing technology, the writing efficiency of communication protocol documents is low and prone to errors and omissions. Software designers need to manually write protocol processing and human-computer interaction interfaces, resulting in low R&D and testing efficiency.
By formalizing the communication protocol, the communication protocol processing class source code and human-computer interaction interface are automatically generated. The interface library function is used to generate a unified style interface, and the Excel spreadsheet protocol document is used for verification and conversion to generate a standardized protocol description document.
It achieves the standardization and accuracy of communication protocols, improves R&D and testing efficiency, standardizes the content of software documentation, and ensures the accuracy and consistency of the generated software work products.
Smart Images

Figure CN120669964A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software design in electronic information technology, and in particular to a method for automatically generating software work products by defining protocol data. Background Art
[0002] A communication protocol is an agreement for transmitting various messages between devices in a communication system. For the drafter of a protocol document, it usually needs to be manually written to be implemented. The efficiency and accuracy of its implementation are related to factors such as the drafter's own ability. For the user of the protocol document, what they receive is often a protocol document in paper or PDF format. Due to the lack of editable protocol definitions, manual writing is required when drafting other software documents such as software requirement specifications, software interface specifications, software design specifications, system / subsystem specifications and other related chapters, as well as when writing protocol-related software, which is prone to errors. For software designers, even if there are editable protocol documents, they still need to manually write protocol processing and human-computer interaction interface programs, which is inefficient and often requires repeated debugging to meet the requirements.
[0003] As software engineering requirements become increasingly stringent, the proportion of software in communication systems increases, and there are more and more software projects, there is an urgent need for a "define once, use in multiple places" method to achieve the automation of three types of software work products: protocol processing source code, protocol description documents, and software interfaces. Summary of the Invention
[0004] The purpose of the present invention is to provide a method for automatically generating software work products that can improve R&D and testing efficiency, standardize software document content, and automatically generate C++ source code for protocol processing classes, human-computer interaction interfaces, and verification software.
[0005] The technical solution for achieving the purpose of the present invention is: a method for automatically generating software work products by defining protocol data, comprising the following steps:
[0006] Step 1: Formalize the communication protocol;
[0007] Step 2: Automatically generate source code for communication protocol processing class;
[0008] Step 3: Separately describe the relevant contents of the instruction worksheet to complete the representation of the human-computer interaction interface;
[0009] Step 4: The communication protocol verification software is compiled and run to verify the Excel spreadsheet protocol document and the communication protocol, and the interface library function automatically generates an interface with a unified style;
[0010] Step 5: Convert the Excel spreadsheet protocol document to automatically generate a communication protocol description document.
[0011] Compared with the prior art, the present invention has the following significant advantages:
[0012] (1) The formal representation of the communication protocol fully expresses the protocol frame structure and the data structure of each instruction, as well as the expression method and range information of the data itself. The source code of the communication protocol class generated by this representation can be compiled and verified by the compiler;
[0013] (2) Using the formal representation of the communication protocol, the style of the setting interface can be intuitively represented. For the attributes required by the interface, it is only necessary to add attribute description phrases in the relevant positions of the table. The interface resources generated by these representations can be verified after being converted into actual interfaces, achieving a unified style and a "what you see is what you get" effect;
[0014] (3) The human-computer interaction interface provides a channel for setting or displaying protocol instructions. Combined with the source code of the communication protocol class, it can form the sending and receiving processing of the protocol instructions and the use and display of the parsing results. It can form two independent sets of test software for the upper computer interface and the lower computer interface, so that "cross-testing" can be easily carried out to achieve self-verification of the test software;
[0015] (4) The message body generated by the formal representation of the verified communication protocol is used as the main body of the protocol description Word document with examples, which ensures the standardization and accuracy of the protocol description and eliminates the defects such as unclear scope and ambiguous definition that may exist in the protocol description document generated by manual editing; (5) The final output software work product is consistent in specifications, accurate, and in line with the protocol concept, which improves the efficiency of R&D testing and standardizes the content of software documents. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 The present invention is a flowchart of a method for automatically generating software work products by defining protocol data.
[0017] Figure 2 Schematic diagram of the column names of the protocol structure worksheet in an embodiment of the present invention.
[0018] Figure 3 Schematic diagram of the column names of the instruction worksheet in an embodiment of the present invention.
[0019] Figure 4-1 This is a structural diagram of the first frame structure in Table 1 of the implementation manner of the present invention.
[0020] Figure 4-2 This is a structural diagram of the second frame structure in Table 1 of the embodiment of the present invention.
[0021] Figure 4-3 This is a structural diagram of the third frame structure in Table 1 of the implementation manner of the present invention.
[0022] Figure 5-1 This is a parameter setting interface diagram generated by the interface library function in Table 3 of the embodiment of the present invention.
[0023] Figure 5-2 This is the operation menu interface diagram generated by the interface library function in Table 3 of the embodiment of the present invention.
[0024] Figure 5-3 This is a state browsing interface diagram generated by the interface library function in Table 3 of the embodiment of the present invention.
[0025] Figure 5-4 This is a data browsing interface diagram generated by the interface library function in Table 3 of the embodiment of the present invention.
[0026] Figure 5-5 This is a repeated structure interface diagram generated by the interface library function in Table 3 of the embodiment of the present invention.
[0027] Figure 6 This is a structural diagram of the main interface automatically generated by the interface library function in an embodiment of the present invention.
[0028] Figure 7 This is a structural diagram of a setting window automatically generated by an interface library function in an embodiment of the present invention.
[0029] Figure 8 This is a structural diagram of a process monitoring window automatically generated by an interface library function in an embodiment of the present invention.
[0030] Figure 9-1 This is a structural diagram of Protocol Example 1 in Table 5 of the implementation mode of the present invention.
[0031] Figure 9-2 This is a structural diagram of Protocol Example 2 in Table 5 of the implementation mode of the present invention.
[0032] Figure 9-3 This is a structural diagram of Protocol Example 3 in Table 5 of the implementation mode of the present invention. DETAILED DESCRIPTION
[0033] The present invention provides a method for automatically generating software work products by defining protocol data, comprising the following steps:
[0034] Step 1: Formalize the communication protocol;
[0035] Step 2: Automatically generate source code for communication protocol processing class;
[0036] Step 3: Separately describe the relevant contents of the instruction worksheet to complete the representation of the human-computer interaction interface;
[0037] Step 4: The communication protocol verification software is compiled and run to verify the Excel spreadsheet protocol document and the communication protocol, and the interface library function automatically generates an interface with a unified style;
[0038] Step 5: Convert the Excel spreadsheet protocol document to automatically generate a communication protocol description document.
[0039] Furthermore, the communication protocol described in step 1 is formally represented as follows:
[0040] Step 1.1: Based on the inherent properties of the communication protocol, formalize the communication protocol, including the definition of the frame structure and the command message body. In an Excel spreadsheet, create a protocol structure worksheet and a command worksheet named "Protocol Structure" and "Command" respectively.
[0041] Step 1.2: The protocol structure worksheet defines three types of data: "frame header," "frame footer," and "instruction key identification location" using "command identifier, protocol type, direction, command description, unit length, characteristic length, element sequence number, element description, element identifier, number of units, bit 0, bit 1, range, explanation, unit, display scale, display accuracy, timeout, number of repetitions, and immediate execution" as columns.
[0042] Step 1.3, the instruction worksheet uses "instruction ID, instruction primary key, direction, instruction description, unit length, characteristic length, element sequence number, element description, element ID, number of units, bit 0, bit 1, range, explanation, unit, display scale, display accuracy, timeout regulation, number of repetitions, immediate execution, element type" as columns to define each instruction one by one.
[0043] Furthermore, in the protocol structure worksheet and instruction worksheet, the items are explained as follows:
[0044] Instruction identifier, which indicates the class name of a single instruction class or frame header class or frame footer class. After conversion, the source code generated is prefixed with "C". For the frame header class, in addition to generating the common class processing source code, the class name indicating the protocol processing class is also generated and prefixed with "Czkprotocol".
[0045] The protocol type appears only in the protocol structure worksheet and is used to specify the structural characteristics of the protocol;
[0046] The instruction primary key only appears in the instruction worksheet and represents the specific value of the instruction number;
[0047] Direction, Alternative Items;
[0048] The command description, i.e. the command name, is fixed as the frame header and frame footer in the protocol structure worksheet;
[0049] Unit length, which indicates the smallest unit used by the protocol. BYTE indicates 8 bits, USHORT indicates 16 bits, and DWORD indicates 32 bits.
[0050] Characteristic length, which indicates the number of minimum units used in this instruction. After conversion into source code, it corresponds to the array size in the instruction data structure.
[0051] The element number is not involved in the conversion and is used to verify the feature length;
[0052] Element description, the name of the parameter in the instruction. For instructions without a message body, "empty information" is named. Parameters that do not need to be set or displayed in the interface are named "unexplained". The converted source code will not describe the parameters containing "unexplained" in the instruction explanation string. For a group of parameters that need to be repeated, "Repeat Start" and "Repeat End" occupy a separate line to represent the array of parameters between them. The maximum value of the array is represented by the number corresponding to the "Number of Units" column of the line where "Repeat Start" is located. If the size of this repeating structure changes dynamically, if the protocol specifies a dynamic length parameter, the parameter name is filled in the "Element Identifier" position of the line where "Repeat Start" is located. If the protocol does not specify a parameter to indicate the size, and the number of repetitions of the repeating structure itself is used to indicate the size, the "Element Identifier" of the line where "Repeat Start" is located should be "Interface Input i" to indicate the number of repetitions specified by the human-computer interaction interface, where i represents the i-th repeating structure in this instruction.
[0053] The element identifier, the name of the parameter in the instruction data structure, will be converted into the variable name in the instruction data structure in the source code, while the element description describes the data structure in the form of comments;
[0054] The number of units, that is, the number of single parameters, corresponds to the array size of the parameters in the instruction data structure. For parameters whose bit fields are not full of unit length, the number of units can only be 1;
[0055] Bit 0, the starting position of the bits occupied by the parameter, starting from 0;
[0056] Bit 1, the end position of the bits occupied by the parameter, the maximum value is the number of units - 1, the conversion program calculates the bit field size of the parameter based on bit 1 and bit 0;
[0057] Range, which limits the range of readable and meaningful parameters of numeric types, using mathematical symbols to represent the boundaries;
[0058] Explanation: A readable and meaningful description of the parameters of the enumeration type;
[0059] Unit, the unit of the parameter, used when interpreting the instruction in the converted source code;
[0060] Display scale. If defined, it indicates a conversion relationship between data and a readable display. Use "#" to distinguish between the conversion relationships of "data → display" and "display → data". Statements related to the conversion relationship should be converted into source code and integrated into the source code.
[0061] Display precision is related to the "display scale". If the display value t is defined as a floating point number, use the "0.1f" method to indicate that the display precision is only to 1 decimal place; if t is an integer and is expected to be displayed in hexadecimal, use the "02X" method to indicate it.
[0062] The timeout provision is only used in the protocol structure worksheet to define the command length in the frame header or to assign a checksum value to the "checksum" parameter in the frame footer;
[0063] Repeat times. In the protocol structure worksheet, for the element at the end of the frame described as a "checksum" parameter, fill in the checksum function statement used in the current cell to explain whether the checksum value is correct. In the instruction worksheet, if the parameter corresponding to the current row is a secondary classification item of the same-value instruction, fill in "Classification" to distinguish cases where the instruction code is the same but the instruction name is different.
[0064] Execute immediately, used for instructions of nested protocol instructions;
[0065] Element type. When protocol data is expressed in different unit lengths, the unit length of a specific parameter is defined separately in the "Element Type". The definition method is the same as the "Unit Length". Add this column when this is needed. By default, this column is empty.
[0066] Furthermore, the automatic generation of the communication protocol processing class source code described in step 2 is as follows:
[0067] The conversion program converts the frame header and frame footer of the instruction worksheet and the protocol structure worksheet in the formal representation of the communication protocol into an independent instruction class, which includes data structure member variables consistent with the instruction worksheet and two member functions for reading and setting. The instruction class has a common base class, which defines common variables and operations for being called by the protocol class, thereby realizing the use of each derived instruction class.
[0068] The protocol class corresponds to the definition of the protocol structure in the protocol structure worksheet, integrating the receiving and sending processing and the analysis of each instruction, using each instruction class as a member variable, and providing a high-level interface. The use of the protocol only requires calling the three functions or variables of receiving, sending, and interpreting to realize the use of the protocol. The conversion program generates .h files and .cpp files.
[0069] Furthermore, the relevant contents of the instruction worksheet described in step 3 are separately explained to complete the representation of the human-computer interaction interface, as follows:
[0070] The formal representation of the communication protocol includes all the human-computer interaction interface information. It is only necessary to separately describe the relevant contents of the instruction worksheet to complete the representation of the human-computer interaction interface, and then use the interface library to directly generate a usable interface. These separate descriptions include "display only" definitions, comment definitions, and a set of multiple lines, a set of single lines and "command" instructions. The interface library will automatically generate an interface that meets expectations based on these descriptions.
[0071] Furthermore, the human-computer interaction representation method is described as follows:
[0072] The interface type is edit, as explained below: For "numeric" type parameters, it means that the parameter is editable. If the string "+display only" is added, the generated interface will be disabled for editing and only for display.
[0073] The interface type is single-select, as explained below: For "enumeration" type parameters, it means that the parameter is a single-select parameter. If the "+display only" string is added, the generated interface will prohibit selection and only be used for display;
[0074] The interface type is multiple selection, as explained below: For "enumeration" type parameters, use "Multiple Selection = m" or "Multiple Selection = m Minimum = n" in the "Range" of the instruction worksheet to define the interface as multiple selection, with a maximum of m and a minimum of n items to be selected. If the "+Display Only" string is added, the generated interface will be disabled for selection and only used for display.
[0075] The interface type is comment, which is explained as follows: For "numeric" type parameters, use the form "[m](n)" in the range of the instruction worksheet to define the default value as m and the comment statement as n;
[0076] The interface type is a group of single lines, as follows: a group of related "numeric" type parameters are presented in a single line;
[0077] The interface type is a group of multiple lines, as follows: a group of related "numeric" type parameters are presented in the form of multiple lines;
[0078] The interface type is command, as follows: fill in the word "command" in the "Unit" field, and fill in the command name in the "Explanation" field in enumeration form. This means that the interface will display the command name in the form of a button. When you click the button, the parameter setting window for the command will pop up.
[0079] The interface type is parameter setting, which is described as follows: It consists of 1 to 7 edit items, single selection, and multiple selection, which can be used to set the parameters of a certain instruction in the worksheet;
[0080] The interface type is an operation menu, which is described as follows: The interface library function converts all instruction names in the "Instruction Description" into an operation menu in the form of a single page or multiple pages;
[0081] The interface type is status browsing, which is explained as follows: the explanation string of the command or the custom string is displayed in the form of "name:value";
[0082] The interface type is data browsing, which is explained as follows: the interpretation string of the command and the original data and time information are displayed in rows;
[0083] The interface type is process monitoring, which is described as follows: It is a parameter setting page that includes parameter display, status display and operation control, and is used to monitor the setting process;
[0084] The interface type is a repeating structure, as explained below: The repeating structure corresponds to the multiple property pages generated by the interface library.
[0085] Furthermore, the communication protocol verification software described in step 4 is compiled and run to mutually verify the Excel spreadsheet protocol document and the communication protocol, and the interface library function automatically generates an interface with a unified style, as follows:
[0086] Step 4.1: The communication protocol verification software is the actual application of the protocol processing class and the human-computer interaction interface. It verifies the communication protocol through compilation and operation.
[0087] Step 4.2: The communication protocol verification software processes the communication protocol mainly in the two processes of receiving and sending. The method of using the protocol processing class is consistent with the representation of the protocol structure worksheet.
[0088] Step 4.3: The communication protocol verification software uses the interface library to represent the human-computer interaction interface, and the interface library function automatically generates an interface with a unified style.
[0089] Furthermore, in step 4.2, the method of using the protocol processing class is consistent with the representation of the protocol structure worksheet, as follows:
[0090] The implementation function is receiving, as described below: In the receiving function, the Receive function of the protocol processing class is called. Receive parses the received data and uses the parsed string information in the m_explain_strs string array for software use. The m_explain_strs string is composed of "name:value" format, which is consistent with the representation of the protocol structure worksheet.
[0091] The implementation function is sending, as described below: Call the Send_Para function of the protocol processing class in the sending queue. The parameters include the instruction name string and the parameter value string array, which are consistent with the representation of the human-computer interaction interface worksheet and the representation of the protocol structure worksheet. The sending instruction is parsed by calling its own Receive function for parsing.
[0092] The implementation function is an example, which is described as follows: through inter-process message passing, the set instructions are set according to the data of the current human-computer interaction interface, and the Send_Para function and Receive of the protocol processing class are used to convert the instructions into raw data strings and parsed strings, which are sent to the conversion program as an example of the instruction, and the conversion program writes the example into the protocol description document.
[0093] Furthermore, in step 4.3, the interface library function automatically generates an interface with a unified style, as follows:
[0094] (1) Main interface
[0095] Verify the software layout's human-computer interaction interface. The interface responds to the mouse and keyboard, using a black background with gray and white display strings. Red indicates editing is enabled or a fault is indicated. Use bold size 5 font, with the size adjusted based on the number of protocol commands and the displayed content. The raw data display area for sending and the raw data display area for receiving are hidden by default, while the status browsing area is displayed by default. Use the Tab key to switch between the two displays. Right-clicking the mouse clears the raw data display content. If paging is required for operating menu items or browsing displayed content, expand it using property pages.
[0096] (2) Settings window
[0097] Click an operation menu to enter the specific settings window. Arrange the items to be set by project name and operation area according to actual needs. If paging is required, expand them using property pages. The operation area is divided into two types: edit controls and selection controls. Edit controls use a fixed-length scroll bar style according to actual needs. Quantities that need to be continuously adjusted can be changed in specified steps using the up and down keys or the mouse wheel. After completing all settings, click the "Execute" button.
[0098] (3) Process monitoring window
[0099] When executing a process, the required information involved in the process is displayed in a table according to actual needs. If debugging functions need to be added, operation control options are added.
[0100] Furthermore, the Excel spreadsheet protocol document is converted as described in step 5 to automatically generate a communication protocol description document, as follows:
[0101] The Excel spreadsheet protocol document compiled and run by the communication protocol verification software is converted to automatically generate a protocol description document; the protocol description document structure is based on Chapter 4.3.2 of GJB438C "System / Subsystem Design Description" and describes one or more protocols in a manner consistent with the protocol document.
[0102] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0103] Example
[0104] Combine Figure 1 The present invention provides a method for automatically generating software work products by defining protocol data, comprising the following steps:
[0105] Step 1: Formalize the communication protocol as follows:
[0106] Step 1.1: Based on the inherent properties of the communication protocol, formalize the communication protocol, including the definition of the frame structure and the command message body. In an Excel spreadsheet, create two worksheets named "Protocol Structure" and "Command" respectively.
[0107] Step 1.2, "Protocol Structure Worksheet" uses "Command Identifier, Protocol Type, Direction, Command Description, Unit Length, Characteristic Length, Element Sequence Number, Element Description, Element Identifier, Number of Units, Bit 0, Bit 1, Range, Explanation, Unit, Display Scale, Display Precision, Timeout, Number of Repetitions, and Immediate Execution" as columns to define three types of data: "Frame Header", "Frame Footer", and "Identification Position of Command Primary Key", such as Figure 2 As shown;
[0108] Step 1.3, "Instruction Worksheet" defines each instruction one by one with "Instruction ID, Instruction Primary Key, Direction, Instruction Description, Unit Length, Characteristic Length, Element Sequence Number, Element Description, Element ID, Number of Units, Bit 0, Bit 1, Range, Explanation, Unit, Display Scale, Display Precision, Timeout, Number of Repetitions, Immediate Execution, and Element Type" as columns, such as Figure 3 As shown;
[0109] The column names of the two worksheets are mostly the same. The instruction worksheet changes the "Protocol Type" in the protocol structure to "Instruction Primary Key" and adds an "Element Type" column. The specific meanings of the column names are shown in Table 1:
[0110] Table 1 Worksheet Item Name Description
[0111]
[0112]
[0113]
[0114] Table 1-1 Structural characteristics of the protocol
[0115]
[0116] Formalizing the representation as described in the table above fundamentally eliminates the "arbitrariness" that exists when drafting the communication protocol. For example, most instruction codes are represented by 2 bytes, and a few are represented by 1 byte. This not only ensures the standardization of the communication protocol structure and consistency of the format, but also allows the converted source code to be embedded in the verification software for compilation and verification to correct unexpected representations, thereby ensuring the accuracy of the communication protocol.
[0117] Step 2: Automatically generate the communication protocol processing class source code, as follows:
[0118] The conversion program converts the frame headers and footers in the "Instruction Worksheet" and "Protocol Structure Worksheet" in the formal representation of the communication protocol into independent instruction classes. These instruction classes include data structure member variables consistent with the instruction worksheet and two main member functions: reading and setting. These instruction classes have a common base class, which defines common variables and operations and can be easily called by the protocol class, thereby realizing the use of each derived instruction class. The protocol class corresponds to the definition of the protocol structure in the "Protocol Structure Worksheet". It integrates the reception and transmission processing and the parsing of each instruction, and uses each instruction class as its member variable to provide a high-level interface. The use of the protocol can be realized by calling only the three functions or variables of reception, transmission, and interpretation. The conversion program generates .h files and .cpp files. The main classes are shown in Table 2:
[0119] Table 2 Classes in the source code
[0120]
[0121] Step 3: The relevant contents of the instruction worksheet are explained separately to complete the representation of the human-computer interaction interface, as follows:
[0122] The formal representation of the communication protocol already contains all the information about the human-computer interaction interface. Therefore, it is only necessary to separately describe the relevant contents of the instruction worksheet to complete the representation of the human-computer interaction interface. Then, the interface library can be used to directly generate a usable interface. These "separate" descriptions include "display-only" definitions, comment definitions, and a group of multi-line, a group of single-line, and "command" instructions. The interface library will automatically generate an interface that meets the expectations based on these descriptions. The main human-computer interaction representation methods are shown in Table 3:
[0123] Table 3 Representation method of human-computer interaction interface
[0124]
[0125] Step 4: The communication protocol verification software is compiled and run to verify the Excel spreadsheet protocol document and the communication protocol. The interface library function automatically generates a unified interface, as follows:
[0126] Step 4.1: The communication protocol verification software is the actual application of the protocol processing class and the human-computer interaction interface. It verifies the communication protocol through compilation and operation.
[0127] Step 4.2: The communication protocol verification software processes the communication protocol mainly in the two processes of receiving and sending. The method of using the protocol processing class is consistent with the representation of the protocol worksheet, as shown in Table 4:
[0128] Table 4 Verification software usage of the main functions of the protocol processing class
[0129]
[0130] Step 4.3: The communication protocol verification software uses the interface library to represent the human-computer interaction interface. The interface library function automatically generates an interface with a unified style, as follows:
[0131] (1) Main interface
[0132] Verify software by Figure 6 The layout of the human-computer interaction interface shown is mouse- and keyboard-responsive. The color scheme uses a black background with gray and white text strings. Red indicates editing or a fault. The font size is bold size 5. The size is adjusted appropriately based on the number of protocol commands and the displayed content. The raw data transmission and raw data reception areas are hidden by default, while the status browsing area is displayed by default. The Tab key switches between the two displays, and the right mouse button clears the raw data content. If paging is required for operating menu items or browsing displayed content, it is expanded using property pages.
[0133] (2) Settings window
[0134] like Figure 7 As shown, clicking an operation menu will bring you to the specific settings window. Arrange the items you want to set by project name and operation area as needed. If paging is required, expand them using property pages. The operation area is primarily divided into two types: edit controls and selection controls. Edit controls can adopt fixed lengths, scroll bars, and other styles based on actual needs. Quantities that require continuous adjustment, such as operating frequency, can be continuously changed in specified steps using the up and down keys or the mouse wheel. After completing all settings, click the "Execute" button.
[0135] (3) Process monitoring window
[0136] like Figure 7 As shown, when executing a process, the required information involved in the process is displayed in a table according to actual needs. If debugging functions need to be added, operation control options can be added.
[0137] Step 5: Convert the Excel spreadsheet protocol document to automatically generate a communication protocol description document. 6. The method for automatically generating a software work product by defining protocol data according to claim 1, wherein the step 5 of converting the Excel spreadsheet protocol document to automatically generate a communication protocol description document is as follows:
[0138] The Excel spreadsheet protocol document compiled and run by the communication protocol verification software is converted to automatically generate a protocol description document. The protocol description document structure is based on Section 4.3.2 of GJB438C "System / Subsystem Design Description" and describes one or more protocols in the same manner as the protocol document, as shown in Table 5:
[0139] Table 5 Protocol description document generation rules
[0140]
[0141] Table 5-1
[0142] Serial number Opcode / Instruction Code Operation / Command Name ... ... ...
[0143] Table 5-2
[0144]
[0145] The communication protocol source code generated by this invention can be used by relevant software designers. Combining the communication protocol source code with a human-computer interaction interface allows for rapid generation of protocol verification and testing software. This software performs cross-checking and multiple verifications on the source code, interface, and documentation, ensuring the quality of the software product. The protocol documentation can then be integrated into officially released software technical documentation and distributed to relevant parties. This invention has been applied in engineering practice. The industry average software productivity rate for GJB5000B Level 3 is 36 lines per person-day, while the document productivity rate is 5 pages per person-day. Automatic generation is completed in seconds. The vast majority of the total time spent on defining the protocol data is comparable to the time it takes a designer to define the protocol data structure in the program. Because this invention achieves low-code generation for one definition, three software products can be automatically generated, and verification software can be generated. Furthermore, it can convert multiple sets of protocol definition files and interface definition files simultaneously, achieving efficiency far greater than three times that of manual work. This has proven to significantly improve the quality and efficiency of software development, maintenance, and upgrades for communication protocols.
[0146] The above are only preferred embodiments of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for automatically generating software work products by defining protocol data, characterized in that The following steps are involved: Step 1: Formalize the communication protocol; Step 2: Automatically generate source code for communication protocol processing class; Step 3: Separately describe the relevant contents of the instruction worksheet to complete the representation of the human-computer interaction interface; Step 4: The communication protocol verification software is compiled and run to verify the Excel spreadsheet protocol document and the communication protocol, and the interface library function automatically generates an interface with a unified style; Step 5: Convert the Excel spreadsheet protocol document to automatically generate a communication protocol description document.
2. The method for automatically generating software work products by defining protocol data according to claim 1, characterized in that: The communication protocol described in step 1 is formally expressed as follows: Step 1.1: Based on the inherent properties of the communication protocol, formalize the communication protocol, including the definition of the frame structure and the command message body. In an Excel spreadsheet, create a protocol structure worksheet and a command worksheet named "Protocol Structure" and "Command" respectively. Step 1.2: The Protocol Structure Worksheet defines three types of data: "Frame Header," "Frame Footer," and "Instruction Key Identification Location" using columns like "Command Identifier, Protocol Type, Direction, Command Description, Unit Length, Characteristic Length, Element Sequence Number, Element Description, Element Identifier, Number of Units, Bit 0, Bit 1, Range, Explanation, Unit, Display Scale, Display Precision, Timeout, Number of Repetitions, and Immediate Execution." Step 1.3: Instruction worksheet, define each instruction one by one using the columns "Instruction ID, Instruction Primary Key, Direction, Instruction Description, Unit Length, Characteristic Length, Element Sequence Number, Element Description, Element ID, Number of Units, Bit 0, Bit 1, Range, Explanation, Unit, Display Scale, Display Precision, Timeout, Number of Repetitions, Immediate Execution, and Element Type." 3. The method for automatically generating software work products by defining protocol data according to claim 2, characterized in that: In the protocol structure worksheet and instruction worksheet, the column descriptions are as follows: Instruction identifier, which indicates the class name of a single instruction class or frame header class or frame footer class. After conversion, the generated source code is prefixed with "C". For the frame header class, in addition to generating the common class processing source code, the class name indicating the protocol processing class is also generated and prefixed with "Czkprotocol". The protocol type appears only in the protocol structure worksheet and is used to specify the structural characteristics of the protocol; The instruction primary key only appears in the instruction worksheet and represents the specific value of the instruction number; Direction, Alternative Items; The command description, i.e. the command name, is fixed as the frame header and frame footer in the protocol structure worksheet; Unit length, which indicates the smallest unit used by the protocol. BYTE indicates 8 bits, USHORT indicates 16 bits, and DWORD indicates 32 bits. Characteristic length, which indicates the number of minimum units used in this instruction. After conversion into source code, it corresponds to the array size in the instruction data structure. The element number is not involved in the conversion and is used to verify the feature length; Element description: The name of the parameter in the instruction. For instructions without a message body, "Empty Information" is used. Parameters that do not need to be set or displayed in the interface are named "Unexplained." Parameters with "Unexplained" will not be described in the instruction explanation string of the converted source code. For a set of parameters that need to be repeated, "Repeat Start" and "Repeat End" occupy separate lines to represent the array of parameters between them. The maximum value of the array is represented by the number corresponding to the "Number of Units" column on the line containing "Repeat Start." If the size of the repeating structure changes dynamically, and if the protocol specifies a dynamic-length parameter, the parameter name is used in the "Element Identifier" position on the line containing "Repeat Start." If the protocol does not specify a parameter to indicate the size, and the number of repetitions of the repeating structure itself is used, the "Element Identifier" position of the "Repeat Start" line should be "Interface Input i" to indicate the number of repetitions specified by the human-computer interaction interface, where i represents the i-th repeating structure in this instruction. The element identifier, the name of the parameter in the instruction data structure, will be converted into the variable name in the instruction data structure in the source code, while the element description describes the data structure in the form of comments; The number of units, that is, the number of single parameters, corresponds to the array size of the parameters in the instruction data structure. For parameters whose bit fields are not full of unit length, the number of units can only be 1; Bit 0, the starting position of the bits occupied by the parameter, starting from 0; Bit 1, the end position of the bits occupied by the parameter, the maximum value is the number of units - 1, the conversion program calculates the bit field size of the parameter based on bit 1 and bit 0; Range, which limits the range of readable and meaningful parameters of numeric types, using mathematical symbols to represent the boundaries; Explanation: A readable and meaningful description of the parameters of the enumeration type; Unit, the unit of the parameter, used when interpreting the instruction in the converted source code; Display scale. If defined, it indicates a conversion relationship between data and a readable display. Use "#" to distinguish between the conversion relationships of "data → display" and "display → data". Statements related to the conversion relationship should be converted into source code and integrated into the source code. Display precision is related to the "display scale". If the display value t is defined as a floating point number, use "0.1f" to indicate that the display precision is limited to 1 decimal place. If t is an integer and is expected to be displayed in hexadecimal, use "02X" to indicate it. The timeout provision is only used in the protocol structure worksheet to define the command length in the frame header or to assign a checksum value to the "checksum" parameter in the frame footer; Repeat times. In the Protocol Structure worksheet, for the "Checksum" parameter at the end of the frame, enter the checksum function statement used in the current cell to determine whether the checksum value is correct. In the Instruction worksheet, if the parameter corresponding to the current row is a secondary classification item for the same-value instruction, enter "Classification" to distinguish between situations where the instruction code is the same but the instruction name is different. Execute immediately, used for instructions of nested protocol instructions; When the protocol data is expressed in different unit lengths, define the unit length of a specific parameter in "Element Type" separately. The definition method is the same as "Unit Length". Add this column when necessary. By default, this column is empty.
4. The method for automatically generating software work products by defining protocol data according to claim 1, characterized in that: The automatic generation of the communication protocol processing class source code described in step 2 is as follows: The conversion program converts the frame header and frame footer of the instruction worksheet and the protocol structure worksheet in the formal representation of the communication protocol into an independent instruction class, which includes data structure member variables consistent with the instruction worksheet and two member functions for reading and setting. The instruction class has a common base class, which defines common variables and operations for being called by the protocol class, thereby realizing the use of each derived instruction class. The protocol class corresponds to the definition of the protocol structure in the protocol structure worksheet, integrating the receiving and sending processing and the analysis of each instruction, using each instruction class as a member variable, and providing a high-level interface. The use of the protocol only requires calling the three functions or variables of receiving, sending, and interpreting to realize the use of the protocol. The conversion program generates .h files and .cpp files.
5. The method for automatically generating software work products by defining protocol data according to claim 1, characterized in that: The relevant contents of the instruction worksheet described in step 3 are explained separately to complete the representation of the human-computer interaction interface, as follows: The formal representation of the communication protocol includes all the information about the human-computer interaction interface. It is only necessary to separately describe the relevant contents of the instruction worksheet to complete the representation of the human-computer interaction interface, and then use the interface library to directly generate a usable interface. These separate descriptions include "display only" definitions, comment definitions, and a set of multi-line, a set of single-line and "command" instructions. The interface library will automatically generate an interface that meets the expectations based on these descriptions.
6. The method for automatically generating software work products by defining protocol data according to claim 5, characterized in that: The human-computer interaction representation method is described as follows: The interface type is edit, as explained below: For "numeric" type parameters, it means that the parameter is editable. If the string "+display only" is added, the generated interface will be disabled for editing and only for display. The interface type is single-select, as explained below: For "enumeration" type parameters, it means that the parameter is a single-select parameter. If the "+display only" string is added, the generated interface will prohibit selection and only be used for display; The interface type is multiple selection, as explained below: For "Enumeration" type parameters, use "Multiple Selection = m" or "Multiple Selection = m Minimum = n" in the "Range" field of the instruction worksheet to define the interface as multiple selection. A maximum of m items can be selected, and a minimum of n items can be selected. If the "+Display Only" string is added, the generated interface will be disabled for selection and will be used for display only. The interface type is comment, which is explained as follows: For "numeric" type parameters, use the form "[m](n)" in the range of the instruction worksheet to define the default value as m and the comment statement as n; The interface type is a group of single lines, as follows: a group of related "numeric" type parameters are presented in a single line; The interface type is a group of multiple lines, as follows: a group of related "numeric" type parameters are presented in multiple lines; The interface type is command, as follows: enter "command" in the "Unit" field and enter the command name in enumeration form in the "Explanation" field. This means that the interface will display the command name in the form of a button. When you click the button, the parameter setting window for the command will pop up. The interface type is parameter setting, which is described as follows: It consists of 1 to 7 edit items, single selection, and multiple selection, which can be used to set the parameters of a certain instruction in the worksheet; The interface type is an operation menu, as described below: The interface library function converts all instruction names in the "Instruction Description" into an operation menu in the form of a single page or multiple pages; The interface type is status browsing, which is explained as follows: the command interpretation string or custom string is displayed in the form of "name:value"; The interface type is data browsing, which is explained as follows: the interpretation string of the command and the original data and time information are displayed in rows; The interface type is process monitoring, which is described as follows: It is a parameter setting page that includes parameter display, status display and operation control, and is used to monitor the setting process; The interface type is a repeating structure, as explained below: The repeating structure corresponds to the multiple property pages generated by the interface library.
7. The method for automatically generating software work products by defining protocol data according to claim 1, characterized in that: The communication protocol verification software described in step 4 is compiled and run to mutually verify the Excel spreadsheet protocol document and the communication protocol. The interface library function automatically generates an interface with a unified style, as follows: Step 4.1: The communication protocol verification software is the actual application of the protocol processing class and the human-computer interaction interface. It verifies the communication protocol through compilation and operation. Step 4.2: The communication protocol verification software processes the communication protocol mainly in the two processes of receiving and sending. The method of using the protocol processing class is consistent with the representation of the protocol structure worksheet. Step 4.3: The communication protocol verification software uses the interface library to represent the human-computer interaction interface, and the interface library function automatically generates an interface with a unified style.
8. The method for automatically generating software work products by defining protocol data according to claim 1, characterized in that: In step 4.2, the method of using the protocol processing class is consistent with the representation of the protocol structure worksheet, as follows: The implementation function is receiving, as described below: In the receiving function, the Receive function of the protocol processing class is called. Receive parses the received data and uses the parsed string information in the m_explain_strs string array for software use. The m_explain_strs string is composed of "name:value" format, which is consistent with the representation of the protocol structure worksheet. The implementation function is sending, as described below: Call the Send_Para function of the protocol processing class in the sending queue. The parameters include the instruction name string and the parameter value string array, which are consistent with the representation of the human-computer interaction interface worksheet and the representation of the protocol structure worksheet. The sending instruction is parsed by calling its own Receive function for parsing. The implementation function is an example, which is described as follows: through inter-process message passing, the set instructions are set according to the data of the current human-computer interaction interface, and the Send_Para function and Receive of the protocol processing class are used to convert the instructions into raw data strings and parsed strings, which are sent to the conversion program as an example of the instruction, and the conversion program writes the example into the protocol description document.
9. The method for automatically generating software work products by defining protocol data according to claim 1, characterized in that: In step 4.3, the interface library function automatically generates an interface with a unified style, as follows: (1) Main interface Verify the software layout's human-computer interaction interface. The interface responds to the mouse and keyboard, using a black background with gray and white display strings. Red indicates editing is enabled or a fault is indicated. Use bold size 5 font, with the size adjusted based on the number of protocol commands and the displayed content. The raw data display area for sending and the raw data display area for receiving are hidden by default, while the status browsing area is displayed by default. Use the Tab key to switch between the two displays. Right-clicking the mouse clears the raw data display content. If paging is required for operating menu items or browsing displayed content, expand it using property pages. (2) Settings window Clicking an operation menu will bring you to the specific settings window. Arrange the items you want to set by project name and operation area as needed. If paging is required, expand them using property pages. Operation areas are divided into two types: edit controls and selection controls. Edit controls use a fixed-length scroll bar style as needed. Quantities that require continuous adjustment can be adjusted in specified steps using the up and down keys or the mouse wheel. After completing all settings, click the "Execute" button. (3) Process monitoring window When executing a process, the required information involved in the process is displayed in a table according to actual needs. If debugging functions need to be added, operation control options are added.
10. The method for automatically generating software work products by defining protocol data according to claim 1, characterized in that: The Excel spreadsheet protocol document is converted as described in step 5 to automatically generate a communication protocol description document, as follows: The Excel spreadsheet protocol document compiled and run by the communication protocol verification software is converted to automatically generate a protocol description document; the protocol description document structure is based on Chapter 4.3.2 of GJB438C "System / Subsystem Design Description" and describes one or more protocols in a manner consistent with the protocol document.