Automatic generation system and method for software code frameTechnical Field
The invention belongs to the technical field of computers, and particularly relates to an automatic generation technology of a software code frame.
Background
Along with the promotion of the software-defined automobile process, the rapid promotion of the software product increasingly reflects the core competitiveness of an automobile enterprise, but the rapid iteration of the software product brings higher requirements to the engineering development period, quality, management and the like of automobile electronic software, and based on the requirements, the automobile software field is also standardized and exported successively, such as Classic Autosar or Adaptive Autosar, and the aim is to improve the multiplexing rate and portability of the software, shorten the development period and ensure the development quality of the software, but in many scenes, developers are still required to carry out code design, for example: insufficient funds to purchase a company or item of commercial software; in cases where there are special restrictions, such as limited platform resources, unsupported development environments, unsupported personnel capabilities, immature or not yet popular relevant specification standards, etc. Therefore, under various scenes requiring code design, the scheme can be intuitively and effectively automatically converted into the code frame, the automatic generation level and quality of the software architecture are increased, and the method has positive significance for software engineering development.
Disclosure of Invention
The invention aims to provide an automatic generation system and method for a software code frame, which solve the technical problems that: the traditional generation of a software code framework is inefficient and of low quality, requiring significant effort from the developer.
In order to solve the technical problems, the invention adopts the following technical scheme: an automatic generation system of a software code frame, which automatically generates a module-level software code frame based on a time sequence chart, a code rule, engineering interaction instructions, a frame module and a serialization rule;
The system comprises:
the code rule loading and analyzing module is used for loading, analyzing and identifying the designated code rule configuration file;
The scheme time sequence loading and analyzing module is used for loading and information extraction operation of scheme time sequences which are output objects designed by the software architecture design and the detailed scheme design;
the frame module rule loading and analyzing module is used for loading the code frame template and caching the code template information;
The serialization rule module is used for realizing serialization and inverse serialization of transmission information when the external interfaces of the modules interact;
the data structure generation module is used for combining the scheme time sequence information, the module information and the frame template information to generate a data structure necessary for codes;
The state machine generation module is used for combining the scheme time sequence information, the module information and the frame template information to generate a module state machine;
the internal interface generation module is used for generating a series of internal interfaces of the module;
the external interface generation module is used for generating external serial interfaces of the module;
The software framework information fusion module is used for integrating the code rule loading and analyzing module, the scheme time sequence loading and analyzing module, the framework module rule loading and analyzing module, the serialization rule module, the data structure generating module, the state machine generating module, the internal interface generating module and the external interface generating module and classifying calculation results;
and the software code frame output module is used for outputting the series files to finish the generation of the software code frame so as to improve the quality and the generation efficiency of the software code frame.
Preferably, the method comprises the steps of,
In the code loading and analyzing module, the code rule configuration file comprises excel, xml, json formats, the configured rules comprise Misra c and Misra c++, the configured rules comprise prefix rules, and the prefix rules comprise the specification of a prefix, namely a module generation file name, an external interface, a macro, an internal interface and a static variable.
Preferably, the method comprises the steps of,
In the scheme time sequence loading and analyzing module, the language rule identified by the module comprises a time sequence diagram described by unified modeling language UML, and module objects, interaction relations, interface names and parameter elements in the time sequence diagram are checked and extracted.
Preferably, the method comprises the steps of,
In the framework module rule loading and analyzing module, the framework template comprises a software template level template on a software unit and a task module template of MCU RTOS level, and also comprises the logic from the process entrance to the hardware initialization, the kernel object creation, the abnormal signal processing registration, the thread creation and the thread inside under Linux.
Preferably, the method comprises the steps of,
In the serialization rules module, the presettable serialization rules include Json, protobuf.
Preferably, the method comprises the steps of,
In the data structure generation module, data structures necessary for enumeration, structure type, and macro code are generated.
Preferably, the method comprises the steps of,
The state machine generation module comprises a state of a software module, an external trigger event and a state event matrix formed by the state of the software module and the external trigger event.
Preferably, the method comprises the steps of,
In the internal interface generation module, an interface of a state machine is included;
and in the external interface generating module, calling an interface of the serial number rule module to generate a serialization file or a compiling file of the external interface and the corresponding interface incidental information.
Preferably, the method comprises the steps of,
In the software code framework output module, the series of files include a data structure file, a state event interface file, an external interface file, a serialization file or a compiling file and a custom interface file.
The invention also provides a method for automatically generating the software code frame, which comprises the following steps:
S01, loading and analyzing and identifying the designated code rule configuration file;
S02, loading and information extraction operation is carried out on an output object which is a scheme time sequence and is designed through a software architecture and a detailed scheme;
s03, loading a code frame template and caching code template information;
s04, serializing and de-serializing transmission information;
S05, combining scheme time sequence information, module information and frame template information to generate a data structure necessary for codes;
s06, combining the scheme time sequence information, the module information and the frame template information to generate a module state machine;
S07, generating a serial interface in the module;
S08, generating a module external serial interface;
s09, integrating the processing result signals of the S01 to the S08 and classifying the calculation result;
S10, outputting a series of files to finish the output of the software code frame so as to improve the quality and the generation efficiency of the software code frame.
By adopting the technical scheme, the invention has the following technical effects: the invention can improve the automatic generation efficiency of the software code frame, reduce the investment of developers and improve the quality of the software code frame. Under various scenes requiring code design, the scheme can be intuitively and effectively automatically converted into a software code frame, the automatic generation level and quality of the software architecture are increased, and the method has positive significance for software engineering development.
Drawings
FIG. 1 is a schematic diagram of the components of the software framework generation.
Detailed Description
The invention is further described below with reference to the accompanying drawings.
As shown in FIG. 1, the invention provides an automatic generation system of a software code frame, which can automatically generate a template-level software code frame by inputting a time sequence chart designed by a scheme, optional code rules and engineering interaction instructions through a developer and preset frame templates and serialization rules.
The system comprises:
And the code rule loading and analyzing module is used for loading, analyzing and identifying the designated code rule configuration file. The code rule loading and parsing module loads and parses the code rule configuration file that is specified. Wherein the code rule profile includes, but is not limited to, excel, xml, json format; the rules configured include, but are not limited to, misra C and Misra C++, and particularly include prefix rules for the model blocks, such as the specification of the block's generated file name, external interface, macro, internal interface, static variables, etc.
The scheme time sequence loading and analyzing module is used for loading and information extraction operation of scheme time sequences which are output objects subjected to software architecture design and detailed scheme design. The scheme time sequence loading and analyzing module is responsible for loading and information extraction operation of scheme time sequences which are output objects designed by a software architecture and a detailed scheme. The language rules identified by the module include, but are not limited to, timing diagrams described by Unified Modeling Language (UML), and feature elements such as module objects, interaction relations, interface names and parameters in the timing diagrams are checked and extracted.
The frame module rule loading and analyzing module is used for loading the code frame template and caching the code template information. The framework module rule loading and analyzing module is responsible for loading code framework templates and caching code template information, and the framework templates comprise, but are not limited to, software module level templates on a software unit and task module templates of MCU RTOS level, and especially comprise the steps of starting from a process entry to hardware initialization, kernel object creation, abnormal signal processing registration, thread creation and internal logic of threads under Linux, and provide preset code framework fixing information, such as language environment information, OS and kernel object information, code flow information and the like, for subsequent code framework generation.
And the serialization rule module is used for realizing serialization and inverse serialization of transmission information when the external interfaces of the modules are interacted. The serialization rule module is responsible for serialization and deserialization of transmission information when the external interface of the module is interacted, so as to enhance adaptability and standardization processing of data transmission among the modules, and the presettable serialization rule comprises, but is not limited to Json, protobuf.
And the data structure generation module is used for combining the scheme time sequence information, the module information and the frame template information to generate a module state machine. The data structure generation module is responsible for combining scheme time sequence information, module information and frame template information to flexibly generate a data structure necessary for codes such as enumeration type, structure type, macros and the like.
And the state machine generation module is used for combining the scheme time sequence information, the module information and the frame template information to generate a module state machine. The state machine generating module is responsible for combining scheme time sequence information, module information and frame template information to generate a module state machine, and particularly comprises a state of a software module, an external trigger event and a state event matrix formed by the two, and a developer can realize state machine switching control in a generated state event matrix interface.
And the internal interface generation module is used for generating internal serial interfaces of the module, including interfaces of a state machine.
And the external interface generation module is used for generating an external serial interface of the module, particularly calling the interface of the serial number rule module, so that the serial file or the compiled file containing the corresponding interface incidental information is also included besides the generation of the external interface.
The software code information fusion module is used for integrating the code rule loading and analyzing module, the scheme time sequence loading and analyzing module, the frame module rule loading and analyzing module, the serialization rule module, the data structure generating module, the state machine generating module, the internal interface generating module and the external interface generating module and classifying the calculation results. The software code information fusion module is responsible for integrating all the module information and classifying the calculation result, so that the output of the software code frame is facilitated.
And the software code framework output module is used for outputting serial files, such as a data structure file, a state event interface file, an external interface file, a serial number output or compiling file, a custom interface file and the like.
The invention also provides a method for automatically generating the software code frame, which comprises the following steps:
S01, loading and analyzing the designated code rule configuration file for identification. Wherein the code rule profile includes, but is not limited to, excel, xml, json format; the rules configured include, but are not limited to, misra C and Misra C++, and particularly include prefix rules for the model blocks, such as the specification of the block's generated file name, external interface, macro, internal interface, static variables, etc.
S02, loading and information extraction operation is carried out on an output object which is a scheme time sequence and is subjected to software architecture design and detailed scheme design. The language rules identified by the module include, but are not limited to, timing diagrams described by Unified Modeling Language (UML), and feature elements such as module objects, interaction relations, interface names and parameters in the timing diagrams are checked and extracted.
S03, loading a code frame template and caching code template information. The framework templates include, but are not limited to, software module level templates of the intelligence quotient of the software unit and task module templates of the MCU RTOS level, and especially further include starting from a process entry to hardware initialization, kernel object creation, exception signal processing registration, thread creation and internal logic of threads under Linux, so as to provide preset code framework fixing information, such as language environment information, OS and kernel object information, code flow information and the like, for the subsequent code framework generation.
S04, serializing and de-serializing the transmission information. To enhance the adaptability and standardization process of inter-module data transmission, presettable serialization rules include, but are not limited to Json, protobuf.
S05, combining the scheme time sequence information, the module information and the frame template information to generate a data structure necessary for codes. The data structures necessary for code such as enumeration, structure type, macro, etc. are flexibly generated.
S06, combining the scheme time sequence information, the module information and the frame template information to generate a module state machine. In particular, the state event matrix comprises the state of the software module, the external trigger event and the state event matrix formed by the two, and a developer can realize state machine switching control in the generated state event matrix interface.
S07, generating a serial interface inside the module. Including the interface of the state machine.
S08, generating a module external serial interface. And particularly, calling the interface of the serial number rule module so that the serial file or the compiled file containing the corresponding interface incidental information is generated besides the external interface.
And S09, integrating the processing result signals of the S01 to the S08 and classifying the calculation results. And integrating all the information and classifying the calculation results, so that the output of the software code frame is facilitated.
S10, outputting a series of files to finish the output of the software code frame so as to improve the quality and the generation efficiency of the software code frame. Series files such as data structure files, state event interface files, external interface files, serial number output or compilation files, custom interface files, and the like.
The invention can improve the automatic generation efficiency of the software code frame, reduce the investment of developers and improve the quality of the software code frame. Under various scenes requiring code design, the scheme can be intuitively and effectively automatically converted into a software code frame, the automatic generation level and quality of the software architecture are increased, and the method has positive significance for software engineering development.