A kind of Model-based diagnosis and information flow visual simulation system and method
Technical field
The invention belongs to software development and emulation fields, and in particular to a kind of Model-based diagnosis and information flow can
Depending on changing analogue system and method.
Background technique
With the rapid development of computer technology with the continuous improvement of human demand, the function of software becomes increasingly complex, right
The safety and stability of software requires also increasingly strict.And the competition in market and the individual demand of different clients make software
Development cycle constantly shorten, this proposes strict demand to the exploitation and test job of software.Software development mainly wraps at present
Include demand analysis, software development and software test three phases.Need to write a large amount of source code in software development phase, but
It is that traditional manual coding mode is not only time-consuming and laborious, but also the reliability of code cannot be guaranteed, developer needs will be a large amount of
Energy put into uninteresting written in code rather than in the frame design and logical design of software, this greatly reduces software
Development efficiency.
Currently, improve development phase efficiency approach be using code recycling technology and Code automatic build technology,
The use threshold of existing code reuse and Auto is higher, and layman is difficult to operate and need when in use
A large amount of human configuration and intervention.In the system testing stage, present case is that almost all of System Integration Test is all black
Box test (only knows whether output result is correct, and but diameter is known nothing to the operation road of code), during the test can not
The operating path of program is directly acquired, some information in program operation process can not be also directly obtained.So once surveying
Test result does not meet situation with desired value it is necessary to devote a tremendous amount of time the position to determine mistake, and this considerably increases reparations
Time needed for software defect.Simultaneously as whether traditional test can only to measure result correct, operating path mistake is tied
But correct situation can not distinguish fruit by chance, can hide some dangers for the correctness of software.In addition, software development environment and test wrapper
The separation in border also increases the time cost of software development.
However, from the point of view of model, model has intuitive, reusable etc. excellent in conjunction with the design philosophy of soft project
Point.In field of software development, system model is made of different component model parts, and it is a certain that component model refers to that some energy are completed
The set of the code of Elementary Function, by splicing different component models, combination, relevant parameter being arranged, so that it may as taking product
Wood equally builds a system model.Later, under orderly standard operation, system model can be translated into and can run
Simulation code.
One system model is needed comprising different component models, while a component model also can be contained in difference
System model in, this provides condition for the multiplexing (i.e. the recycling of code) of component.Using model as the performance of system
Mode not only intuitively, but also is also used as showing the carrier of information when system operation, this is conducive in System Integration Test
Position mistake, in addition, Model-based diagnosis developer can be made in the main design for being dropped in system as possible and
It is not to improve the quality for the software designed in uninteresting written in code.
Summary of the invention
For deficiency present in existing software development process and the advantage of model tormulation method, the present invention is intended to provide
A kind of Model-based diagnosis and information flow visual simulation system and method are beneficial to improve software development and software
The efficiency and quality of test job.
To realize above-mentioned technical purpose and the technique effect, the invention is realized by the following technical scheme:
A kind of Model-based diagnosis and information flow visual simulation system, including component model library module, system
Model buildings module, information display module, simulation code generation module, code compilation module and operation control module.
The component model library module is built module with the system model and is connect, and the system model builds module connection
It is connect respectively with the information display module and the simulation code generation module, the simulation code generation module and the generation
Code collector connection, the code compilation module connect with the information display module, the operation control module respectively with
The system model builds module, the information display module, the simulation code generation module and the code compilation module
Connection.
The component model library module, it acts as:
1) information of component model all in management component model library and each component model;
2) addition, modification and deletion of management component model;
3) guarantee the correctness and safety of all component models, build module and the emulation generation for the system model
The work of code generation module provides support.
The system model builds module, it acts as:
1) component model in the component model library is built into system model, in the process, the system model
All information relevant to system model operation is built will be recorded by building module, be mentioned for the work of the simulation code generation module
For supporting;
2) according to the information recorded, the correctness of system model is checked, guarantees the smooth of code building work
It carries out;
3) it is the carrier that artificial intelligence is shown that the system model, which builds the system model of module generation,.
The information display module, it acts as:
It is built with the system model and provides a visual Modeling interface together with module for user, the information is shown
Module by all information during modeling and simulation by certain rule display on this Modeling interface, for user watch with
And carry out corresponding operation.
The Modeling interface has following three functions:
1) structure of the dynamic process and system model of display modeling, specific manifestation form are as follows:
All component models in the component model library will be shown in the form of tree-shaped to be supplied in the Modeling interface
User's selection;When user builds module using the system model and builds system model, can be shown on the Modeling interface
System model, component model and the relevant setting parameter of system model after the component model that is dragged, assembling;
2) flow process of the display artificial intelligence on system model, specific manifestation form are as follows:
The system model put up can be shown on the Modeling interface, read according to the information display module
Emulation data, will do it real-time display on the system model built, reach and make the operating path of simulation code real-time
The effect being shown on system model;
3) system model is helped to build the correctness of module check system model, specific manifestation form are as follows: user
Can intuitively whether correct from the structure of observing system model on the Modeling interface, if there are isolated component model,
Whether parameter configuration is correct.
The simulation code generation module, it acts as:
1) the realization code for utilizing component model, the system model build that module recorded with build system model
Under the guide for operating relevant information, the system code which is translated as to run (is used into the practical C of component model
Code replaces the position of counterpart member model in system model, forms irrelevant code piece, then will be between component model
Topology information, component model and system model parameter configuration reflect into code piece generated, by these
Irrelevant code piece connects into an entirety, the system code that can be run);
2) system code just generated by scanning obtains (i.e. code between the component model being connected in system code
Between piece) position of function call and relevant variable information, and it is (some to have the auxiliary of specific use in these positions insertion probe
Helping property code) generate simulation code;
3) test case that user inputs is inserted into simulation code generated, generates final simulation code.
The code compilation module, it acts as: by the simulation code compiling of simulation code generation module generation, chain
Simulated program can be run by being connected into.
The operation control module, it acts as:
1) other modules are dispatched, the work between modules is coordinated;
2) operation and stopping of simulated program are controlled;
3) it obtains and stores information and control artificial intelligence that simulated program middle probe is dished out;
4) it is interacted by Modeling interface and user, receives the instruction of user.
Further, the system model build that module recorded to be to build the relevant information of system model manipulation to include
Topological structure relationship, component model and system mould between the type of component model included in system model, component model
The parameter configuration of type.
Further, the effect of the probe be obtain simulated program run to herein when relevant variable information and control
The operating status of processing procedure sequence here, but not the operation logic and result of original code are had an impact.
Further, it includes controlling the emulation generation that the operation control module, which dispatches the particular content of other modules,
Code generation module generates simulation code, controls the code compilation module and generates simulated program, the information and control that probe is dished out
Artificial intelligence processed passes to the information display module, and is shown on the system model of Modeling interface.
A kind of Model-based diagnosis and information flow visual simulating method, comprising the following steps:
Step 0) determines software function according to user demand;
Information display module described in step 1) is orderly in the form of structure tree by component model all in component model library
Be shown on Modeling interface, user's function according to needed for software, selection needs component model to be used;
Step 2 is under the support that the system model builds module and the information display module, and user is by required component
Model is dragged and dropped into Modeling interface, and operates on it, and the component model chosen is built into system model;
Step 3) user according to demand, matches the relevant parameter of component model and system model on Modeling interface
It sets, and forms final system model effect picture on Modeling interface;
System model described in step 4), which builds module, will record down all information during building system model, including structure
The parameter configuration of topological structure, component model and system model between part types of models, component model;
Step 5) is under the scheduling of the operation control module, and the simulation code generation module is according to step 4
System model builds the information of module record and the practical C code of component model, and system model is translated into the system that can be run
Then code is inserted into probe in obtained system code, generate simulation code;
Operation control module described in step 6) receives the test case of user's input, and the simulation code is called to generate mould
The test case is inserted into the simulation code that step 5 generates by block, generates final simulation code;
Step 7) calls the code compilation module to generating in step 6 under the scheduling of the operation control module
Simulation code is compiled, and generates the simulated program that can be run;
Operation control module described in step 8) receives beginning emulation command;
The simulated program generated in operation control module rate-determining steps 7 described in step 9) brings into operation;
When simulated program runs to the probe location being inserted into step 5, simulated program can be controlled step 10) to the operation
Molding block issues the request continued to run, and enters wait state;
Operation control module described in step 11) reads the variable information that probe is dished out after receiving request immediately, and to these
Variable information does following processing:
1) variable information is sent to the system model and builds module, and control simultaneously the information display module by this
A little variable informations are shown in the corresponding position of Modeling interface;
2) associated two component models and its interface are obtained according to variable information, and it is aobvious to control the information simultaneously
Show module by the line between the two component models and its interface on Modeling interface to be highlighted;
3) file is recorded in these variable informations to save, so as to subsequent use;
After operation control module described in step 12) has handled the work in step 11, respond immediately in step 10 in etc.
The request command that simulated program to state is issued continues to run;
Step 13) repeats step 10 and arrives step 12, until entire simulated program end of run;If there is actual motion knot
The fruit situation inconsistent with expected results, can be by the operating path of the simulation code shown on observation Modeling interface and each
Variable information at a component model determines problem location and corrects;
Step 14) repeats step 6 and arrives step 13, tests all test cases;
Step 15) terminates.
The beneficial effects of the present invention are:
The thought of model is dissolved into the development process of software by the present invention, proposes a kind of new software development and test
Method improves traditional software development model, improves development efficiency;The present invention is based on reusable component models, use
The mode to play with building blocks builds system model, largely reduces the size of code of hand-coding, will set the work of developer
Center of gravity is transferred in logic and principle design, and improve system can designed capacity;The present invention is visual using artificial intelligence
Mode shows the variable information of the operational process of program and transmitting, by traditional Black-box Testing whitepack, improves and is
The verifying ability for design of uniting.
The above description is only an overview of the technical scheme of the present invention, in order to better understand the technical means of the present invention,
And can be implemented in accordance with the contents of the specification, with presently preferred embodiments of the present invention and attached drawing is cooperated to be described in detail below.This hair
Bright specific embodiment is shown in detail by following embodiment and its attached drawing.
Detailed description of the invention
The drawings described herein are used to provide a further understanding of the present invention, constitutes part of this application, this hair
Bright illustrative embodiments and their description are used to explain the present invention, and are not constituted improper limitations of the present invention.In the accompanying drawings:
Fig. 1 is system framework figure of the invention;
Fig. 2 is operational flow diagram of the invention;
Fig. 3 is the logic chart that operation control module of the invention controls simulated program operation;
Fig. 4 is the structural schematic diagram for a system model being shown on Modeling interface;
Fig. 5 is the first operating path of simulated program of system model shown in Fig. 4;
Fig. 6 is the second operating path of simulated program of system model shown in Fig. 4;
Fig. 7 is the simulated program third operating path of system model shown in Fig. 4;
Fig. 8 is the 4th operating path of simulated program of system model shown in Fig. 4;
Fig. 9 is the 5th operating path of simulated program of system model shown in Fig. 4;
Figure 10 is the 6th operating path of simulated program of system model shown in Fig. 4.
Figure label explanation: 1, component model library module;2, system model builds module;3, information display module;4, it imitates
True code generation module;5, code compilation module;6, operation control module.
Specific embodiment
It is below with reference to the accompanying drawings and in conjunction with the embodiments, next that the present invention will be described in detail.
It is shown in Figure 1, a kind of Model-based diagnosis and information flow visual simulation system, including component model
Library module 1, system model build module 2, information display module 3, simulation code generation module 4, code compilation module 5 and operation
Control module 6.
The component model library module 1 is built module 2 with the system model and is connect, and the system model builds module 2
Connection is connect with the information display module 3 and the simulation code generation module 4 respectively, the simulation code generation module 4
It is connect with the code compilation module 5, the code compilation module 5 is connect with the information display module 3, the operation control
Module 6 builds module 2, the information display module 3, the simulation code generation module 4 and institute with the system model respectively
State the connection of code compilation module 5.
The main function of the component model library module 1 is component model and each structure all in management component model library
Component model is presented to the user in the form of functional unit for using by the information of part model.Component model library is by reading structure
The information of part model, obtain code external component model is provided interface, need external component model offer interface and
The information of acquisition is supplied to user and configured by the information such as the parameter of interface.The component model library module 1 goes back management component
Addition, modification and the deletion of model, as created reflecting between the name of component model, the icon and component model information of component model
Penetrate relationship type.The component model library module 1 also manages all component and mapping relations, guarantees the correct of all component models
Property and safety, for system model build with simulation code generation support is provided.
The system model build module 2 effect be provide one together with the information display module 3 for user can
Depending on the Modeling interface changed, and the component model in the component model library is built into system model on this Modeling interface.
Its specific implementation are as follows: the system model builds the definition of module 2 to the mode of operation of component model, realizes to component model
The selection operation of component model and drag and drop duplication operation, realize the line operation between component model pel, realize to building in library
The operation of the parameter configuration of model and system model.
In the process, the system model is built module 2 also and will be recorded and is all relevant to system model operation is built
Information, topological structure relationship, component model between the type of the component model as included in system model, component model and
The parameter configuration etc. of system model, the work for the simulation code generation module 4 provide support;At the same time, described
System model is built module 2 and can also be checked according to the information recorded the correctness of system model, guarantees code building
Work is gone on smoothly;It is the carrier that artificial intelligence is shown, the system that the system model, which builds the system model that module 2 generates,
The output information for model buildings module 2 of uniting is system model and the file for recording system model relevant information.
The effect of the information display module 3 be built with the system model module 2 provide one together for user can
It is shown by certain rule in this Modeling interface depending on the Modeling interface changed, and by all information during modeling and simulation
On, corresponding operation is watched and carried out for user.
The Modeling interface has following three functions:
1) structure of the dynamic process and system model of display modeling, specific manifestation form are as follows: the component model library
In all component models will in the form of tree-shaped display in the Modeling interface for user select;In the system model
When building module 2 and building system model, the system mould after the component model dragged, assembling can be shown on the Modeling interface
Type, component model and the relevant setting parameter of system model;
2) flow process of the display artificial intelligence on system model, specific manifestation form are as follows: on the Modeling interface
It can show the system model put up, according to the read emulation data of the information display module 3, what is built is
It will do it real-time display on system model, reach and the operating path of simulation code is allowed to be shown in the effect on system model in real time
Fruit;
3) system model is helped to build the correctness that module 2 checks system model, specific manifestation form are as follows: user
Can intuitively whether correct from the structure of observing system model on the Modeling interface, if there are isolated component model,
Whether parameter configuration is correct.
The effect of the simulation code generation module 4 is that system model is translated as simulation code.Its specific implementation
Be the simulation code generation module 4 first pass through that the parsing system model builds that module 2 recorded with build system model
Relevant information is operated, the wherein type, name of all component models, topology information, interface recalls information are obtained and is connect
Mouth configuration information, recycles the realization code of component model, the system code that system model is translated as to run (is used component
The practical C code of model replaces the position of counterpart member model in system model, irrelevant code piece is formed, then by structure
The parameter configuration of topology information, component model and system model between part model reflects to code piece generated
In, these irrelevant code pieces are connected into an entirety, the system code that can be run);Then just by scanning
The system code of generation, obtain system code in be connected component model between (i.e. between code piece) position of function call and
Relevant variable information, and generation is emulated in these positions insertion probe (some complementary codes for having specific use) to generate
Code;Finally, the test case that user inputs is inserted into simulation code generated, final simulation code is generated.
The effect of the probe be obtain program run to herein when relevant variable information and control program here
Operating status, but not the operation logic and result of original code are had an impact.
The effect of the code compilation module 5 is the simulation code compiling for generating the simulation code generation module 4, chain
Simulated program can be run by being connected into.
The effect of the operation control module 6 is to dispatch other modules, coordinates the work between modules, including
It controls the simulation code generation module 4 and generates simulation code, control the code compilation module 5 and generate simulated program, control
The operation and stopping of simulated program obtain, the information dished out of storage simulated program middle probe and control artificial intelligence, and by these
Information passes to the information display module 3, is shown on the system model of Modeling interface, passes through Modeling interface and user
It interacts, receives the instruction of user.
Most important of which is that the operation and stopping of control simulated program and obtaining artificial intelligence and in system model figure
Upper display.Shown in Figure 3, realization principle is as follows: visiting when simulated program runs to the insertion of simulation code generation module 4
When the position of needle, simulated program meeting operation suspension simultaneously issues the request continued to run, the operation to the operation control module 6
Control module 6 determines the position that request issues after receiving request first, the information that probe is dished out then is read, by parsing information
The information such as component name, interface name and the interface parameters for occurring that component model interface calls are obtained, then send these information
It is shown to the information display module 3, keeps corresponding component and line highlighted.The operation controls after completing these work
Module 6 replys the request that simulated program issues and agrees to continue with operation, and simulated program continues to run down after receiving reply, if again
The secondary probe that encounters then repeats the above process.
Referring to fig. 4 shown in -10, Fig. 4 indicates a system model put up on Modeling interface, the system model
It is made of 8 component models;Fig. 5 indicates that the simulated program of the system model brings into operation, and the system model on Modeling interface is defeated
It is highlighted to enter end;Fig. 6 indicates that, when simulated program is run to component 1, system model input terminal and component 1 are highlighted;Fig. 7 expression is worked as
When simulated program is run to probe location between component 1 and component 2, system model input terminal, component 1, component 2 and its between
Line it is highlighted;Fig. 8 shows when simulated program is run to probe location between component 2 and component 7, system model input
End, component 1, component 2, component 7 and its between line it is highlighted;Fig. 9 indicates to run when simulated program to component 7 and component 8
Between probe location when, system model input terminal, component 1, component 2, component 7, component 8 and its between line it is highlighted;
Figure 10 expression is when simulated program operation finishes, system model input terminal, component 1, component 2, component 7, component 8, system model
Output end and its between line it is highlighted.
Simulation code is tested using different test cases, if simulation result is inconsistent with expected results,
It can determine problem location simultaneously by the variable information at the operating path and each node of simulated program on observation Modeling interface
Correction.System model is tested in a manner of visual, the efficiency and quality of System Integration Test can be greatly improved.
It is shown in Figure 2, a kind of Model-based diagnosis and information flow visual simulating method, including following step
It is rapid:
Step 0) determines software function according to user demand;
Information display module 3 described in step 1) is orderly in the form of structure tree by component model all in component model library
Be shown on Modeling interface, user's function according to needed for software, selection needs component model to be used;
Step 2 is under the support that the system model builds module 2 and the information display module 3, and user is by required structure
Part model is dragged and dropped into Modeling interface, and operates on it, and the component model chosen is built into system model;
Step 3) user according to demand, matches the relevant parameter of component model and system model on Modeling interface
It sets, and forms final system model effect picture on Modeling interface;
System model described in step 4), which builds module 2, will record down all information during building system model, including
The parameter configuration of topological structure, component model and system model between component model type, component model;
Step 5) is under the scheduling of the operation control module 6, and the simulation code generation module 4 is according to institute in step 4
State system model build module 2 record information and component model practical C code, system model is translated into can run be
System code, is then inserted into probe in obtained system code, generates simulation code;
Operation control module 6 described in step 6) receives the test case of user's input, and the simulation code is called to generate
The test case is inserted into the simulation code that step 5 generates by module 4, generates final simulation code;
Step 7) calls the code compilation module 5 to generate in step 6 under the scheduling of the operation control module 6
Simulation code be compiled, generate the simulated program that can run;
Operation control module 6 described in step 8) receives beginning emulation command;
The simulated program generated in 6 rate-determining steps 7 of operation control module described in step 9) brings into operation;
When simulated program runs to the probe location being inserted into step 5, simulated program can be controlled step 10) to the operation
Molding block 6 issues the request continued to run, and enters wait state;
Operation control module 6 described in step 11) reads the variable information that probe is dished out after receiving request immediately, and to these
Variable information does following processing:
1) variable information is sent to the system model and builds module 2, and controlling the information display module 3 simultaneously will
These variable informations are shown in the corresponding position of Modeling interface;
2) associated two component models and its interface are obtained according to variable information, and it is aobvious to control the information simultaneously
Show module 3 by the line between the two component models and its interface on Modeling interface to be highlighted;
3) file is recorded in these variable informations to save, so as to subsequent use;
After operation control module 6 described in step 12) has handled the work in step 11, respond immediately in step 10 in etc.
The request command that simulated program to state is issued continues to run;
Step 13) repeats step 10 and arrives step 12, until entire simulated program end of run;If there is actual motion knot
The fruit situation inconsistent with expected results, can be by the operating path of the simulated program shown on observation Modeling interface and each
Variable information at a component model determines problem location and corrects;
Step 14) repeats step 6 and arrives step 13, tests all test cases;
Step 15) terminates.
Simply to illustrate that technical concepts and features of the invention, its purpose is allows in the art above-described embodiment
Those of ordinary skill cans understand the content of the present invention and implement it accordingly, and it is not intended to limit the scope of the present invention.It is all
It is changes or modifications equivalent made by the essence of content according to the present invention, should be covered by the scope of protection of the present invention.