CN102629213B - Analysis method and monitoring method for C language simulation model - Google Patents

Analysis method and monitoring method for C language simulation model Download PDF

Info

Publication number
CN102629213B
CN102629213B CN201210041375.3A CN201210041375A CN102629213B CN 102629213 B CN102629213 B CN 102629213B CN 201210041375 A CN201210041375 A CN 201210041375A CN 102629213 B CN102629213 B CN 102629213B
Authority
CN
China
Prior art keywords
class
mark
variable
decomposing
grammatical
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201210041375.3A
Other languages
Chinese (zh)
Other versions
CN102629213A (en
Inventor
杨盈
范智刚
罗喜霜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Runke General Technology Co Ltd
Original Assignee
Beijing Jingwei Hirain Tech Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingwei Hirain Tech Co Ltd filed Critical Beijing Jingwei Hirain Tech Co Ltd
Priority to CN201210041375.3A priority Critical patent/CN102629213B/en
Publication of CN102629213A publication Critical patent/CN102629213A/en
Application granted granted Critical
Publication of CN102629213B publication Critical patent/CN102629213B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention provides an analysis method for a C language simulation model. A C code analysis method category is generated by grammar files in advance, wherein the C code analysis method category comprises a syntax analysis module, a lexical analysis module and a syntax tree generation module. The method includes the steps that the lexical analysis module in the C code analysis method category is called to analyze lexical content of the imported C language simulation model, so as to form a token flow; the syntax analysis module is called to analyze the syntax content of the imported C language simulation model according to the token flow; the syntax tree generation module is called to generate a corresponding syntax tree according to the syntax content obtained through analysis; and information is extracted from the syntax tree and stored in a model information file. The invention further provides a monitoring method of the C language simulation model. The monitoring method comprises the analysis method. The analysis method and the monitoring method provided by the invention fill in the present blanks in the C language simulation model analysis and monitoring technology in china, and the implementation processes of the analysis method and the monitoring method are simple.

Description

A kind of anatomy of C language realistic model and method for supervising
Technical field
The present invention relates to computer simulation technique field, particularly relate to a kind of anatomy and method for supervising of C language realistic model.
Background technology
The core of computer simulation technique comprises realistic model and emulation platform.Realistic model is the abstractdesription to simulated entity object characteristic, has the mathematics similar to entity and physical attribute, the characteristic sum rule of reflection entity.The description of realistic model can by various computerese as formula translation, C language, M language etc., carry out coding according to the coding rule of correspondence to realize, also realize as MATLAB/Simulink carries out the building of basic mathematical computing module such as addition subtraction multiplication and division in the mode played with building blocks by modeling tool.The realistic model no matter described in which way, finally all needs to be compiled into executable application program, downloads on emulation platform and carry out simulation and calculation.
Emulation platform is the carrier that realistic model resolves, and is made up of software and hardware, and accordingly, real-time simulation platform is made up of real-time oss simulation computer of unifying.In order to realize real-time simulation, i.e. realistic model real-time resolving, carries out data interaction with peripherals in real time, then need realistic model compiling to download to implement emulation platform runs.Therefore, complete real-time simulation platform generally includes emulation host computer and emulation slave computer.Emulation host computer runs a simulation management software, be responsible for carrying out model compiling the model described by computerese or by the model that modeling tool is built, generate executable application program, and download to emulation slave computer by network communications such as Ethernets.Emulation slave computer is responsible for real-time resolving and has been compiled the realistic model generating executable application programs.When model is when emulating slave computer and carrying out simulation and calculation, emulation host computer needs to extract the variable data in realistic model, and online instant playback, so that whether the personnel of emulation have a clear understanding of realistic model calculation result correct, simultaneously, emulation personnel can carry out manual intervention, the parameter in online modification realistic model, and realistic model is resolved according to the result of emulation personnel budget.In order to realize extraction to realistic model built-in variable parameter and amendment, carry out before real-time simulation resolves at realistic model, need to dissect realistic model, namely to the information in realistic model, comprise function name and parametric variable name and variable number, module parameter, global variable etc. extract, be kept in message file.
At present, for the model using modeling tool MATLAB/Simulink to build, the TLC template file that can be provided by amendment MATLAB/Simulink realizes the anatomy to realistic model, and for the anatomy of the realistic model using C language coding rule to write, domestic also do not have suitable method, it can only be built into MATLAB/Simulink model again at present, more just can realize parsing process by TLC template file, this method will cause unnecessary, a large amount of repeated work.In addition, in practical engineering application, most of realistic model adopts C language to write, if can not dissect C language, by the range of application of restriction C language realistic model.
Summary of the invention
In view of this, the invention provides a kind of anatomy and method for supervising of C language realistic model, the problem of unnecessary, a large amount of repeated work can be caused for solving existing anatomy and method for supervising.
A kind of method for decomposing of C language realistic model, in advance by grammatical file generated C code method for decomposing class, described grammatical file under speech recognition too development environment by developer's hand-coding, wherein, generate after described C code method for decomposing class compiles grammatical file by speech recognition instrument, it comprises syntax Analysis Module, Lexical Analysis Module and syntax tree generation module;
The method comprises:
The lexical content of Lexical Analysis Module to the C language realistic model imported called in C code method for decomposing class dissects, and forms mark stream;
Call the syntax Analysis Module in C code method for decomposing class, according to described mark stream, the syntactic structure of the C language realistic model imported is dissected;
The syntax tree generation module called in C code method for decomposing class generates corresponding syntax tree according to the syntactic structure that described analysis obtains;
From described syntax tree, extract variable information sum functions information, and the variable information sum functions information of described extraction is saved in model information file.
Preferably, described speech recognition instrument is the speech recognition instrument ANTLR that increases income.
The compiling procedure of described grammatical file comprises:
Determine the integral frame of grammatical file, by the division of teaching contents of described grammatical file be: head module, option mod, syntax analyzer generic module and lexical analyzer generic module, described head module and described option mod, for defining the essential information of grammatical file, described syntax analyzer generic module, for defining the grammatical analysis content that grammatical file comprises, described lexical analyzer generic module, for the lexical analysis content comprised due to grammatical file;
Define the grammatical analysis content that grammatical file comprises;
Define the lexical analysis content that grammatical file comprises;
Add distinctive Jave class methods, described distinctive Jave class methods do not become for described ANTLR is raw but carries out the distinctive java class method required for the anatomy of C code.
Described grammatical analysis content comprises: data type mark, structure or community identification, data structure variable list mark, enumeration type mark, variable array mark, pointer mark, parameter list mark, identifier list mark.
Described lexical analysis content comprises: character type marking variable, special character mark, 16 system marks, 10 system marks, 8 system marks, floating number mark, block annotation form mark, row annotation mark.
Described C code method for decomposing class is C code method for decomposing java class, C code method for decomposing C++ class or C code method for decomposing C# class.
A method for supervising for C language realistic model, comprising:
Host computer simulation management software transfer C language compiler compiles the C language realistic model imported, and compiling generates executable application program;
Host computer simulation management software adopts the method for decomposing of above-mentioned C language realistic model to dissect the C language realistic model imported;
Described executable application programs is downloaded to emulation slave computer by host computer simulation management software, carries out the real-time resolving of model;
Variable information in model information file is extracted the model variable that will carry out monitoring to emulation personnel and from the variable information described model information file by host computer simulation management software by showing interface, and the described model parameter that will monitor is sent to emulation slave computer, emulation slave computer is according to variable name, the data of corresponding described variable name are extracted from internal memory, return to host computer simulation management software to show, if will modify to variable, the variable name then directly will revised and the data of correspondence thereof send to emulation slave computer, data corresponding for the described variable name that will revise are write in internal memory corresponding to the described variable name that will revise by emulation slave computer.
The invention provides a kind of anatomy and method for supervising of C language realistic model, the method is write grammatical file in advance and is generated C code method for decomposing class, and by using C code method for decomposing class to dissect C language realistic model and monitor, implementation procedure is simple.Method provided by the invention has filled up the blank of current domestic C language realistic model anatomy and monitoring technique, and the grammatical file content write is complete, goes for anatomy and the monitoring requirement of most of C language realistic model.
Accompanying drawing explanation
In order to be illustrated more clearly in the embodiment of the present invention or technical scheme of the prior art, be briefly described to the accompanying drawing used required in embodiment or description of the prior art below, apparently, accompanying drawing in the following describes is only embodiments of the invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to the accompanying drawing provided.
The process flow diagram of the method for decomposing of the C language realistic model that Fig. 1 provides for the embodiment of the present invention one;
The compiling procedure figure of the grammatical file that Fig. 2 provides for the embodiment of the present invention one;
The process flow diagram of the method for supervising of the C language realistic model that Fig. 3 provides for the embodiment of the present invention two.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, be clearly and completely described the technical scheme in the embodiment of the present invention, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, belong to the scope of protection of the invention.
Embodiment one
The embodiment of the present invention one provides a kind of method for decomposing of C language realistic model, before carrying out the method, in advance by grammatical file generated C code method for decomposing class, C code method for decomposing class comprises syntax Analysis Module, Lexical Analysis Module and syntax tree generation module, the process flow diagram of the method for decomposing that Fig. 1 provides for the embodiment of the present invention, the method comprises:
S11: the lexical content of Lexical Analysis Module to the C language realistic model imported called in C code method for decomposing class dissects, and forms mark stream;
S12: call the syntax Analysis Module in C code method for decomposing class, according to mark stream, dissects the syntactic structure of the C language realistic model imported;
S13: the syntax tree generation module called in C code method for decomposing class generates corresponding syntax tree according to analyzing the syntactic structure obtained;
S14: extract variable information sum functions information from syntax tree, and the variable information sum functions information of extraction is saved in model information file.
Wherein, grammatical file by developer's hand-coding, generates after C code method for decomposing class compiles grammatical file by speech recognition instrument under speech recognition too development environment.In the present embodiment, speech recognition instrument is the speech recognition instrument ANTLR that increases income.
In the present embodiment, the compiling procedure of grammatical file as described in Figure 2, comprising:
S21: the integral frame determining grammatical file, by the division of teaching contents of grammatical file be: head module header, option mod options, syntax analyzer generic module parser and lexical analyzer generic module lexer, wherein, head module header and option mod options, for defining the essential information of grammatical file, syntax analyzer generic module parser, for defining the grammatical analysis content that grammatical file comprises, lexical analyzer generic module lexer, for the lexical analysis content comprised due to grammatical file;
S22: define the grammatical analysis content that grammatical file comprises, comprises data type mark (as void type, char type, float type etc.), structure or community identification, data structure variable list mark, enumeration type mark, variable data mark, pointer mark, parameter list mark, identifier list mark.Wherein, in data type mark, the type also comprising that simulink is distinctive, do not have in standard C, as int8_T, cuint16_T etc., after identifying, the type_specifier position of grammatical file is programmed according to ANTLR grammar rule, such as, literary style during definition data type is: key word (type_specifier), line feed put in a colon (:), after add data type identification (mark adds single quotation marks), if want the multiple data type of link definition, then line feed add " | " connect afterwards again data type mark, as follows:
type_specifier
:′void′
|′char′
|′short′
|′int′
|′long′
|′float′
|′double′
……
S23: define the lexical analysis content that grammatical file should comprise, comprise: character type marking variable, n the special character such as t mark, 16 systems marks, 10 systems marks, 8 systems marks, floating number mark, block annotation form mark, row annotation mark, identify out, the relevant position of grammatical file is programmed in by ANTLR grammar rule, such as, 16 system marks are defined as follows:
HEX_LITERAL:′0′(′x′|′X′)HexDigit+IntegerTypeSuffix?
S24: add distinctive Jave class methods, namely add ANTLR life not become, but the distinctive Java method of carrying out required for the anatomy of C code, as the method for decomposing of constructed fuction part, addition manner adds self-defining special member function code by key word@member, by key word@lexer::header, add self-defining java class, as:
@lexer::header{
package com.hirain.hisim.redundancy.parse.antlr;
}
In the present embodiment, the grammatical file after having write is compiled, generate C code method for decomposing java class, certainly also can generate C code method for decomposing C++ class, C# class.Wherein, C code method for decomposing java class comprises Lexer class (morphology class) and Parser class (syntactic class) two class files.Under this C code method for decomposing java class being copied to emulation host computer respective path, for the software transfer of host computer simulation management, host computer simulation management software is according to lexical analysis, the corresponding module that the sequence call C code method for decomposing class that grammatical analysis and generative grammar are set provides, then from content comprehensive syntax tree tree structure, required content is extracted, and the content of extraction is saved in model information file .hisim, wherein, function name is comprised in tree structure, parametric variable name, variable number, all information such as global variable, cover all information of grammatical file defined.
When emulating an importing C language realistic model on host computer, host computer simulation management software meeting Automatically invoked C code method for decomposing java class, the C language realistic model imported is dissected, generation model message file, thus realize the anatomy object to C language realistic model.
The method for decomposing of the C language realistic model provided by the embodiment of the present invention, when dissecting C language realistic model, it again will not be built into MATLAB/Simulink model and dissect, therefore, implementation procedure is simple.
Embodiment two
The embodiment of the present invention two provides a kind of method for supervising of C language realistic model, the process flow diagram of the method for supervising that Fig. 3 provides for the embodiment of the present invention, and the method comprises:
S31: host computer simulation management software transfer C language compiler compiles the C language realistic model imported, compiling generates executable application program;
S32: host computer simulation management software adopts the method for decomposing of the C language realistic model in embodiment one to dissect the C language realistic model imported;
S33: executable application program is downloaded to emulation slave computer by host computer simulation management software, carries out the real-time resolving of model;
S34: the variable information in the model information file that the method for decomposing by embodiment one obtains by host computer simulation management software by showing interface to emulation personnel, and from the variable information model information file, extract the model variable that will carry out monitoring, the model parameter that will monitor sends to emulation slave computer, emulation slave computer is according to variable name, the data of corresponding variable name are extracted from internal memory, return to host computer simulation management software to show, if will modify to variable, the variable name then directly will revised and the data of correspondence thereof send to emulation slave computer, the data that the variable name that will revise of emulation slave computer is corresponding are write in internal memory corresponding to the variable name that will revise.
The method for supervising of the C language realistic model that the embodiment of the present invention provides has filled up the blank of domestic C code anatomy and monitoring technique, make C language realistic model in real-time emulation system, realize on-line monitoring and become possibility, simultaneously, use the anatomy of speech recognition instrument ANTLE realization to C language realistic model of increasing income, implementation procedure is simple, reliable.In addition, the grammatical file content that the embodiment of the present invention is write is complete, goes for most of C language realistic model and dissects the requirement used.
To the above-mentioned explanation of the disclosed embodiments, professional and technical personnel in the field are realized or uses the present invention.To be apparent for those skilled in the art to the multiple amendment of these embodiments, General Principle as defined herein can without departing from the spirit or scope of the present invention, realize in other embodiments.Therefore, the present invention can not be restricted to these embodiments shown in this article, but will meet the widest scope consistent with principle disclosed herein and features of novelty.

Claims (5)

1. the method for decomposing of a C language realistic model, it is characterized in that, in advance by grammatical file generated C code method for decomposing class, described grammatical file under speech recognition too development environment by developer's hand-coding, wherein, generate after described C code method for decomposing class compiles grammatical file by speech recognition instrument, described C code method for decomposing class comprises syntax Analysis Module, Lexical Analysis Module and syntax tree generation module;
The method comprises:
The lexical content of Lexical Analysis Module to the C language realistic model imported called in C code method for decomposing class dissects, and forms mark stream;
Call the syntax Analysis Module in C code method for decomposing class, according to described mark stream, the syntactic structure of the C language realistic model imported is dissected;
The syntax tree generation module called in C code method for decomposing class generates corresponding syntax tree according to the syntactic structure that described anatomy obtains;
From described syntax tree, extract variable information sum functions information, and the variable information sum functions information of described extraction is saved in model information file;
Wherein:
Described grammatical analysis content comprises: data type mark, structure or community identification, data structure variable list mark, enumeration type mark, variable array mark, pointer mark, parameter list mark, identifier list mark;
Described lexical analysis content comprises: character type marking variable, special character mark, 16 system marks, 10 system marks, 8 system marks, floating number mark, block annotation form mark, row annotation mark.
2. method according to claim 1, is characterized in that, described speech recognition instrument is the speech recognition instrument ANTLR that increases income.
3. method according to claim 2, is characterized in that, the compiling procedure of described grammatical file comprises:
Determine the integral frame of grammatical file, by the division of teaching contents of described grammatical file be: head module, option mod, syntax analyzer generic module and lexical analyzer generic module, described head module and described option mod, for defining the essential information of grammatical file, described syntax analyzer generic module, for defining the grammatical analysis content that grammatical file comprises, described lexical analyzer generic module, for defining the lexical analysis content that grammatical file comprises;
Define the grammatical analysis content that grammatical file comprises;
Define the lexical analysis content that grammatical file comprises;
Add distinctive Jave class methods, described distinctive Jave class methods do not become for described ANTLR is raw but carries out the distinctive java class method required for the anatomy of C code.
4. method according to claim 1, is characterized in that, described C code method for decomposing class is C code method for decomposing java class, C code method for decomposing C++ class or C code method for decomposing C# class.
5. a method for supervising for C language realistic model, is characterized in that, comprising:
Host computer simulation management software transfer C language compiler compiles the C language realistic model imported, and compiling generates executable application program;
Host computer simulation management software adopts as the method in claim 1-4 as described in any one dissects the C language realistic model imported;
Described executable application programs is downloaded to emulation slave computer by host computer simulation management software, carries out the real-time resolving of model;
Variable information in model information file is extracted the model variable that will carry out monitoring to emulation personnel and from the described variable information described model information file by host computer simulation management software by showing interface, and the described model variable that will monitor is sent to emulation slave computer, emulation slave computer is according to variable name, the data of corresponding described variable name are extracted from internal memory, return to host computer simulation management software to show, if will modify to variable, the variable name then directly will revised and the data of correspondence thereof send to emulation slave computer, data corresponding for the described variable name that will revise are write in internal memory corresponding to the described variable name that will revise by emulation slave computer.
CN201210041375.3A 2012-02-21 2012-02-21 Analysis method and monitoring method for C language simulation model Active CN102629213B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210041375.3A CN102629213B (en) 2012-02-21 2012-02-21 Analysis method and monitoring method for C language simulation model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210041375.3A CN102629213B (en) 2012-02-21 2012-02-21 Analysis method and monitoring method for C language simulation model

Publications (2)

Publication Number Publication Date
CN102629213A CN102629213A (en) 2012-08-08
CN102629213B true CN102629213B (en) 2015-02-04

Family

ID=46587473

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210041375.3A Active CN102629213B (en) 2012-02-21 2012-02-21 Analysis method and monitoring method for C language simulation model

Country Status (1)

Country Link
CN (1) CN102629213B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103631632B (en) * 2013-11-29 2017-08-04 华为技术有限公司 Implantation method and source-to-source compiler
CN107229616B (en) * 2016-03-25 2020-10-16 阿里巴巴集团控股有限公司 Language identification method, device and system
CN112579058A (en) * 2019-09-27 2021-03-30 陕西星邑空间技术有限公司 Application program development method and related device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH09282173A (en) * 1996-04-10 1997-10-31 Hitachi Ltd Static analysis method for program
CN101017458A (en) * 2007-03-02 2007-08-15 北京邮电大学 Software safety code analyzer based on static analysis of source code and testing method therefor
CN101271421A (en) * 2007-03-22 2008-09-24 北京邮电大学 Software fault test system and method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH09282173A (en) * 1996-04-10 1997-10-31 Hitachi Ltd Static analysis method for program
CN101017458A (en) * 2007-03-02 2007-08-15 北京邮电大学 Software safety code analyzer based on static analysis of source code and testing method therefor
CN101271421A (en) * 2007-03-22 2008-09-24 北京邮电大学 Software fault test system and method

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
模型驱动的嵌入式仿真系统设计;李秀萍等;《计算机工程》;20100831;第36卷(第16期);第237-239页 *
组态化嵌入式软件仿真系统设计;姬祥等;《计算机工程》;20111130;第37卷(第21期);第225-227,231页 *

Also Published As

Publication number Publication date
CN102629213A (en) 2012-08-08

Similar Documents

Publication Publication Date Title
Burden et al. Natural language generation from class diagrams
CN102708098B (en) Dependency coherence constraint-based automatic alignment method for bilingual words
WO2004036340A3 (en) A method, a language and a system for the definition and implementation of software solutions
CN109032577B (en) Data simulation method
Riddle et al. Software development tools
CN108804136A (en) Configuration item type constraint inference method based on name semantics
CN103942086A (en) AADL-based method for establishing, analyzing and simulating hybrid system model
KR20160063990A (en) COMPUTER-EXECUTABLE MODEL reverse engineering mETHOD AND APPARATUS PERFORMING THE SAME
CN102629213B (en) Analysis method and monitoring method for C language simulation model
Blanchard et al. Towards full proof automation in Frama-C using auto-active verification
Riviere et al. EB4EB: a framework for reflexive Event-B
Schulte Neutral networks of real-world programs and their application to automated software evolution
CN101470607A (en) Data normalization method
CN103150445B (en) The method for decomposing of a kind of MATLAB model variable and device
CN107122184A (en) A kind of virtual reality software open type developing system and method
Filipovikj et al. Analyzing industrial simulink models by statistical model checking
CN115904480A (en) Code reconstruction method and device, electronic equipment and storage medium
CN102662728B (en) A kind of proof of algorithm method and system
Fitzgerald et al. Triumphs and challenges for the industrial application of model-oriented formal methods
Hopwood Decompilation.
CN103810335A (en) Complex system parallel simulation oriented assembly type description method
CN113448874A (en) Method and device for generating unit test script
Neukirchen et al. Quality assurance for TTCN‐3 test specifications
CN108492168A (en) Property tax industry audit emulation mode
Bussenot et al. A domain specific test language for systems integration

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CP03 Change of name, title or address

Address after: 4 / F, building 1, No.14 Jiuxianqiao Road, Chaoyang District, Beijing 100020

Patentee after: Beijing Jingwei Hengrun Technology Co.,Ltd.

Address before: 100101 Beijing city Chaoyang District Anxiang Beili 11 B block 8 layer

Patentee before: Beijing Jingwei HiRain Technologies Co.,Ltd.

CP03 Change of name, title or address
TR01 Transfer of patent right

Effective date of registration: 20230612

Address after: 100192 5th floor, Zhizhen building, 7 Zhichun Road, Haidian District, Beijing

Patentee after: BEIJING RUNKE GENERAL TECHNOLOGY Co.,Ltd.

Address before: 4 / F, building 1, No.14 Jiuxianqiao Road, Chaoyang District, Beijing 100020

Patentee before: Beijing Jingwei Hengrun Technology Co.,Ltd.

TR01 Transfer of patent right