CN103885816A - Simulation method of real-time embedded system - Google Patents

Simulation method of real-time embedded system Download PDF

Info

Publication number
CN103885816A
CN103885816A CN201410122430.0A CN201410122430A CN103885816A CN 103885816 A CN103885816 A CN 103885816A CN 201410122430 A CN201410122430 A CN 201410122430A CN 103885816 A CN103885816 A CN 103885816A
Authority
CN
China
Prior art keywords
event
class
converted
time
uml
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.)
Granted
Application number
CN201410122430.0A
Other languages
Chinese (zh)
Other versions
CN103885816B (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.)
Nanjing University
Original Assignee
Nanjing University
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 Nanjing University filed Critical Nanjing University
Priority to CN201410122430.0A priority Critical patent/CN103885816B/en
Publication of CN103885816A publication Critical patent/CN103885816A/en
Application granted granted Critical
Publication of CN103885816B publication Critical patent/CN103885816B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention provides a simulation method of a real-time embedded system. Firstly, an XMI document is read, and elements of the XMI document are divided into a class diagram element collection and a sequence chart element collection; then the class diagram element collection is converted to be C++ codes; on the basis of the C++ codes of class diagrams, the sequence chart element collection is converted to be C++ codes; a Simulink model is converted to be C++ codes through a Simulink Coder, clock interrupt is added, and the C++ codes become real-time codes; then the C++ codes and the real-time codes are combined together according to the set in a class diagram model, an executable file can be compiled and generated, the executable file operates on a target platform, then the simulation of the whole real-time embedded system is achieved, and a test result is given. According to the method, automatic codes of the class diagram model, a sequence chart model and the Simulink model based on UML can be generated, time constraint information is extracted, simulation is carried out by executing the generated codes, and a result report whether the time constraint of the system is met or not is given.

Description

A kind of emulation mode of real time embedded system
Technical field
The present invention utilizes UML and Simulink to realize the emulation of real time embedded system, and the time-constrain of extracting from sequence chart is tested, and belongs to the interleaving techniques field of soft project, model-driven engineering and system emulation.
Background technology
The exploitation of real time embedded system application usually relates to multiple subjects, as electronic engineering, mechanical engineering and soft project etc.Although these subjects are combined closely in embedded system, their exploitation is usually series process.Be generally first to design mechanical part, then hardware facility is fixed, and finally develops embedded software.This method can cause a lot of problems, especially for soft project personnel.For example, the selection of the position of sensor, speed control, delay control, hardware etc., these complexities for software have a significant impact.And, there is a lot of implicit assumed condition just can manifest first in the time of the system integration, can cause like this can not find best scheme.
UML (unified modeling language, Unified Modeling Language) is the modeling language being in fashion the most, and field of software engineering is often used the model-driven based on UML to develop as early as possible and pinpointed the problems.Simulink is in the world Modelling of Dynamic System emulation tool all the fashion, can be applied to the many fields that relate to engineering and mathematics, and its powerful graphical modeling function has greatly improved the development efficiency of Simulation Application.
Simulink Coder can be C/C++ code by Simulink model conversion, and support plurality of target environment: current main frame, real-time simulator, flush bonding processor, targeted environment can be monokaryon or multinuclear, can be the part that stand-alone computer also can be used as network service.
Summary of the invention
Technical matters: time-to-violation retrains or violates continually them and can cause grave error in real-time system, and then can produce threat to the mankind's life or environment.In order effectively embedded real time system to be tested in early days, be badly in need of a kind of strategy that is carried out to automatic test the time.UML and Simulink represent the different view of a product, and wherein UML is used for describing software configuration and behavior, and Simulink is used for obtaining the different aspect of system action.Existing method can not support the model of class figure, sequence chart model and the Simulink of UML to communicate and detect the mistake of violating real-time constraint, the object of the invention is to address the above problem, a kind of emulation mode of real time embedded system of cross-module type of robotization is provided, to break different interdisciplinary traditional serial development approaches, make in the just feasibility of detection system and time-constrain to a certain extent of design phase.
Technical scheme: first the present invention reads and resolve the uml model of the real time embedded system that preserve, that treat emulation based on XMI form, converts them to C++ code; Then use instrument by treat emulation real time embedded system Simulink module converts for C++ code and add clock interrupt; Finally more above-mentioned C++ code is automatically merged and carries out emulation, provide simulation result.
The emulation mode of a kind of real time embedded system that the present invention proposes comprises the following steps:
Step 1) is read in the uml model of preserving based on XMI form from disk file.
Described uml model comprises uml class graph model, UML sequence chart model; Described uml class graph model is the model of the class in descriptive system and the relation between them; Uml class graph model comprises following UML standard component: bag element, dvielement, interface element, data type element, basic data type element, enumeration element, signal element, comment element, and above-mentioned element is the maximum unit that uml class graph model is converted to C++ code; Described UML sequence chart model is that sending and receiving order by message between description object is to show the model of dynamic cooperative between multiple objects; UML sequence chart model comprises following UML standard component: interactive elements, and this element is that UML sequence chart model conversion is the maximum unit of C++ code; Described XMI uses a kind of object-oriented of XML exchange metadata information to organize OMG standard language; Described XML a kind ofly makes it have structural extend markup language for electroactive marker son file.
Step 2) element in uml model is divided in element class diagram set and sequence chart element set.
Step 21) obtain all elements that uml model comprises.
Step 22) if wrap element, dvielement, interface element, data type element, basic data type element, enumeration element, signal element, comment element, added element class diagram set.
Step 23) if interactive elements adds sequence chart element set.
The uml class graph model of the real time embedded system for the treatment of emulation is converted to C++ code by step 3).
Step 31) in the time also there is non-switched element class diagram in element class diagram set, read a non-switched element class diagram; Otherwise go to step 4).
Step 32) if current element class diagram is bag element, generate a .h file, state therein a NameSpace .h filename and NameSpace name are this element term.
Step 33) if current element class diagram is dvielement, generate a .h file and a .cpp file, this element is converted to a class in C++, go to step 310).
Step 34) if current element class diagram is interface element, generate a .h file and a .cpp file, the open method that this element is converted in C++ is all abstract class of pure virtual function, goes to step 310).
Step 35) if current element class diagram is data type element, generate a .h file and a .cpp file, this element is converted to a class in C++, go to step 310).
Step 36) if current element class diagram is fundamental type element, do not process.
Step 37) if current element class diagram is signal element, generate a .h file and a .cpp file, this element is converted to a class in C++, go to step 310).
Step 38) if current element class diagram is enumeration element, generate a .h file, enumerate, go to step 31 for one that this element is converted in C++).
Step 39) if current element class diagram is comment element, generate a C++ annotation, go to step 31).
Step 310) obtain the element that current element class diagram relies on, the header file title of the element relying on is comprised to the header file into currentElement, and use its NameSpace.
Step 311) obtain the element that current element class diagram is had to dependence, in the corresponding class of currentElement, the corresponding class that relies on element is made as to friendly metaclass, the header file title of the element relying on is comprised to the header file into currentElement.
Step 312) obtain the extensive all elements of current element class diagram, make currentElement public inheritance they; The header file title of these elements is comprised into current header file, and use its NameSpace.
Step 313) obtain current element class diagram by association, paradigmatic relation, the associated element of syntagmatic, according to associated multiplicity and observability suitable add a member variable, before variable, add one " * "; The header file title of associated element is comprised into current header file, and use its NameSpace.
Step 314) obtain the nested type element of current element class diagram inside and add element class diagram set, go to step 31).
Step 4) is C++ code by the UML sequence chart model conversion of the real time embedded system for the treatment of emulation.
Step 41) be temporal expression, time interval, duration interval, time observation, duration observation, time-constrain, a class of the each generation of these UML element types of duration constraints, and in the generation class of time-constrain and duration constraints, add a Boolean function for judging whether satisfied constraint of time.
Step 42) in the time that sequence chart element set also exists non-switched sequence chart element, read a non-switched sequence chart element; Otherwise go to step 5).
Step 43) current sequence figure element is decomposed into by time observation element, duration observation element, time-constrain element, duration constraints element, state invariant, controls the mutual fragment that focus element and message element form.
Step 431) precondition of current sequence figure element and postcondition are converted to and are asserted, and be placed on front position and the rearmost position of current sequence figure element entrance function.
Step 432) run into mutual use element, the .h file of specified mutual generation class is comprised in the .h file of current generation class; Create the object of a specified mutual generation class, using the object associated lifeline that uses alternately covering and the message that need to import into as entrance function parameter; The entrance function of allocating object.
Step 433) run into continuous types of elements, according to its title and setting, alt or seq combination are coupled together alternately.
Step 434) run into common region types of elements, all partial order sequences of the event sets it directly being comprised are deleted from the partial ordering set of sequence chart.
Step 435) run into combined fragment types of elements, decompose it.
Step 4351) if interactive operation symbol is alt, is illustrated in current combined fragment and has at the most an interactive operation territory to carry out; Each Operand is translated as to a conditional statement, the guard condition of Operand is converted to conditional expression.
Step 4352) if interactive operation symbol is opt, represent a kind of optional behavior, interactive operation territory is converted to a conditional statement, the guard condition of operation domain is converted to conditional expression.
Step 4353) if interactive operation symbol is break, transfer interactive operation territory to conditional branch statements, the guard condition in interactive operation territory is converted to conditional expression, last sentence of this conditional branch statements piece is break statement.
Step 4354) if interactive operation symbol is par, represent a kind of parallel behavior, each interactive operation territory is converted to a thread function.
Step 4355) if interactive operation symbol is seq, do not process.
Step 4356) if interactive operation symbol is loop, be converted to loop statement, the guard condition in interactive operation territory is converted to conditional expression.
Step 4357) if interactive operation symbol is critical, be converted into critical section.
Step 44) event sets is divided.
Step 441) if type three is gathered, divide event sets, make the each set after dividing become type two set; Then according to the related lifeline of these event sets, they are divided to level, the event sets executed in parallel of every one deck, and set between level keeps Serial Relation,, after upper strata event sets is finished, the event sets of lower one deck starts to carry out; Described type two set refer to that the event sets of sequence chart is partial ordering relation, and for any two message m sg1 and msg2, msg1 has at least an event to compare with the event of msg2; Described type three set refer to that the event sets of sequence chart at least can be divided into two set setA, setB, and for any message msgB in any message msgA and SetB in setA, the event of msgA and the event of msgB cannot compare.
Step 442) if type two gather, add suitable sequence relation to existing partial ordering set, make afterwards, in the time that event sets is carried out to topological sorting, not only will to observe its existing order of occurrence, also will consider the semanteme that the type of the message at event place is expressed.
Step 45) transfer the each event sets after dividing to hierarchy chart, in figure, node is event; Described hierarchy chart refers to according to controlling focus event sets is divided into different levels, in the time not occurring controlling focus, be the 1st layer, often run into one and control focus, event all can increase one deck, event under the same control focus of every layer from left to right successively sorts by occurring, and the event in every layer can be converted to the specific implementation of the associated message of its father node.
Step 46) all time observations, duration observation, time-constrain, duration constraints element are put into corresponding event.
Step 47) state invariant element is converted to and the condition of asserting of its next event in same lifeline.
Step 48) hierarchy chart is converted to C++ code: a time of origin that sends function and receiver function and be used for respectively recording transmission event and the event of reception is provided, when each asynchronous message is received, can open a new thread and carry out this message, the transcode of each event can write in the corresponding function of message of his father's Node Events association.
Step 49) entrance function using the transcode of ground floor event as this sequence chart element calls the Boolean function of all time-constrains and duration constraints example print result in this entrance function; Go to step 42).
Step 5) is C++ code by Simulink Coder by the Simulink model conversion of the real time embedded system for the treatment of emulation; The call back function that uses multimedia timer, advances its emulation with the frequency of fixing; Described Simulink model is to use Simulink to carry out the model of modeling gained; Affiliated Simulink is a kind of data stream figure programming language tools for modeling, emulation and analysis multiple domain dynamic system; Described Simulink Coder a kind ofly can and carry out the instrument of C/C++ from Simulink model generation.
Step 6) code merges: in the C++ code of being changed by Simulink Coder, contain input parameter structure, output parameter structure, initialization function and stop function; The code place changing in the operation of application <<SimCode>GreatT .GreaT.GT, the parameter correspondence of operation is imported in corresponding Simulink model parameter, and called successively initialization function and stop function.
The C++ code that above step 7) Complied executing, step conversion is come, offers user result.
Beneficial effect: the invention provides a kind of class figure based on UML and the cross-module type emulation mode of sequence chart model and Simulink model automatization, break different interdisciplinary traditional serial development approaches, made in the just feasibility of detection system and time-constrain to a certain extent of design phase.Specifically, the method under the present invention has following beneficial effect:
(1) in the emulation mode based on uml class figure, sequence chart model and Simulink model of the present invention, realize the automatic conversion that class figure, sequence chart arrive C++ code, realize the automatic fusion of the transcode of Simulink model and the transcode of uml model, make in the just feasibility of detection system and time-constrain to a certain extent of design phase, the code after fusion can be used as follow-up exploitation basis.
(2) emulation mode based on uml class figure, sequence chart model and Simulink model of the present invention, although initial object is to be used in the design phase, but also can be for the iterative increment exploitation of system, modeling personnel can replace the module of existing use uml model or Simulink model realization at any time by the module of having developed, and carry out real-time testing by emulation.
Brief description of the drawings
The emulation mode process flow diagram of class graph model, sequence chart model and the Simulink model of Fig. 1 based on UML,
Fig. 2 event sets is that type one is gathered the sequence chart that meets ordering relation,
Fig. 3 event sets is the sequence chart that type two is gathered,
Fig. 4 event sets is the sequence chart that type three is gathered,
Fig. 5 sequence chart,
Fig. 6 changed by Fig. 5 and hierarchy chart.
Embodiment
For a more detailed description to the specific embodiment of the present invention below in conjunction with Fig. 1.
One, read and change
Read XMI document by the XmiReader class in org.eclipse.xtend.typesystem.emf.Carry out the conversion of model to code with Xpand.Before becoming an assembly of Eclipse, Xpand is the part as openArchitectureWare project at first.Xpand is a kind of template instruction of static types.It has following feature: the polymorphic template of calling, and Aspect-oriented programming, can carry out Function Extension, and type system is abstract flexibly one, model conversion, modelling verification etc.
Two, conversion class figure
In concrete enforcement, can provide two version types (Stereotype): <<CppCode>GreatT .GreaT.GT, <<SimCode>GreatT .GreaT.GT, can only use certain operation of one of them application and class at the most.A codeSegment attribute in <<CppCode>GreatT .GreaT.GT is used as the specific code of current operation, targetName is used to specify the document location of having realized the method, and the targetName in <<SimCode>GreatT .GreaT.GT has specified the Simulink module title that realizes the method.
Change being specifically implemented as follows of a class independent in class figure:
(1) obtain all properties element that currentElement comprises, property element is converted to a member variable that generates class, its name attribute value is member variable name, and its type attribute value is member variable type.
(2) obtain all operations element that currentElement comprises, each operation element is converted to a member function that generates class; Obtain the possessive construction type element that is applied to each operation element, if this stereotyped element is <<CppCode>GreatT .GreaT.GT element, if codeSegment non-NULL, the character string in codeSegment field realizes as the specific code of current operation; If targetName non-NULL, the specific implementation using the content of the file of its sensing as current operation.
(3) obtain all reception elements that currentElement comprises, each reception element is converted to a member function that generates class, function name is the name property value of Reception types of elements, the Signal types of elements that first parameter type of function is its appointment, all the other parameters are the parameter himself comprising, function body part is the code conversion of the behavior of its appointment, is temporarily empty, when processing sequence chart, adds and again.
(4) obtain the element that currentElement relies on, the header file title of the element relying on is comprised to the header file into currentElement, and use its NameSpace.
(5) obtain the element that currentElement is had to dependence, in the corresponding class of currentElement, the corresponding class that relies on element is made as to friendly metaclass, the header file title of the element relying on is comprised to the header file into currentElement.
(6) obtain the extensive all elements of currentElement, make currentElement public inheritance they; The header file title of these elements is comprised into current header file, and use its NameSpace.
(7) obtain currentElement by association, paradigmatic relation, the associated element of syntagmatic, according to associated multiplicity and observability suitable add a member variable, before variable, add one " * "; The header file title of associated element is comprised into current header file, and use its NameSpace;
(8) obtain the nested type element of currentElement inside, convert them to corresponding types.
Three, conversion sequence figure
Sequence chart is converted to a general code, and user can repeatedly test by simple modification suction parameter (such as parameter of the constructed fuction of class etc.).
Each sequence chart is converted to a class, generates a .h file and a .cpp file, after such, can carry out this sequence chart in instantiation by its entrance function.
A sequence chart can represent with a sequence of events, and between the event of sequence chart, acquiescence is weak sequence, do not have so to walk abreast between common participant's event, and event sets is a partial ordering set.
(1) aggregate type
For representing conveniently, to use M={m 0..., m n-1expression massage set, E={e 1..., e n-1presentation of events set, e used i=! m irepresent message m itransmission event, use e i=m irepresent message m ireception event, by the precedence relationship between < e=E × E presentation of events, each message m iall meet <! m i, m i>.
The event of the same level in sequence chart can present following three kinds of relations: one, event can sort entirely, as shown in Figure 2; Two, event sets is not totally ordered set, and except <! m i, m ioutside >, between the event of any two message in set, have at least a pair of event can compare order, have as shown in Figure 3 < e={ <! Msg1, msg1 >, < msg1,! Msg2 >, a <! Msg2, msg2 >, a <! Msg2,! Msg3 >, a <! Msg3, msg3 > }; Three, in set, there are two message, except <! m i, m ioutside >, between associated event, cannot compare, as shown in Figure 4, can find out between the event of msg1, two message of msg2 and the event of msg3 and cannot compare completely.
Fig. 4 partial order event sets can be divided into following three set: < e 1a={ <! Msg1, msg1 >, < msg1,! Msg2 >, a <! Msg2, msg2 > }, < e 2a={ <! Msg3, msg3 > }, < e 3a={ <! Msg4, msg4 > }, these three set are all partial ordering sets, can open up successively two thread execution < e 1with < e 2interior event, just can ensure to walk abreast between two set, after two thread execution are complete, carries out < e again 3the event of set.
To sum up, the event sets of same level can be divided into three types.
Type one set refers to that the event sets of sequence chart is ordering relation.
Type two set refer to that the event sets of sequence chart is partial ordering relation, and for any two message m sg1 and msg2, msg1 has at least an event to compare with the event of msg2.
Type three set refer to that the event sets of sequence chart at least can be divided into two set setA, setB, and for any message msgB in any message msgA and SetB in setA, the event of msgA and the event of msgB cannot compare.
(2) decomposition type three is gathered and is divided level
To type, three set are divided, and the each set after division is type two set.The execution of some set need to wait for that the set before it is finished, and also wants the lifeline at the event place in set of records ends, and in the time that the lifeline of two set has common factor, a rear set must wait for that previous set is finished.
Divide being specifically implemented as follows of set:
Make EventThread=(ESet eSet, LSet lSet), ESet presentation of events aggregate type, LSet represents lifeline aggregate type, EventThreadList represents the ordered set type that EventThread types of elements forms.
(1) create an EventThreadList example eventThreadList, example epSet, the eqSet of two ESet, and a LSet example lSet, be initially sky.
(2) if there is an event e that preorder event all occurs in epSet, e is added to epSet, the lifeline at its place is added to lSet, make i=0, flag=false; Otherwise exit.
(3) obtain i the element e of epSet i.
(4) obtain e inext event e in the lifeline of place jif its all preorder events are all in set epSet, by e jadd epSet, put flag=true.
(5) if e ibe transmission event, and all preorder event sets of the reception event of its correspondence are all in epSet, by e icorresponding reception event e kadd epSet, by e kthe lifeline at place adds lSet, flag=true.
(6) make i=i+1,
(61) if i < epSet.size () turns (3);
(62) if i >=epSet.size (),
(621) if flag=true turns (2);
(622) if flag=false deletes the transmission event that does not have corresponding reception event in epSet; The object eventThread that creates an EventThread type, deposits the difference set of epSet and eqSet and l in this object; The object l that re-creates a LSet type, makes eqSet=epSet, and eventThread is added to eventThreadList, turns (2).
Can obtain an eventThreadList through above-mentioned algorithm, each element is wherein all type two set.
Also need divide level according to lifeline, specifically be implemented as follows:
Make Layer represent the ordered set type of EventThreadList type.
(1) create a Layer type instance layer, create an EventThreadList example eventThreadListTemp, make i=0.
(2) if i >=eventThreadList.size () finishes.
(21) order
eventThread i=eventThreadList.get(i),
If
&cup; j = 0 eventThreadListTemp . size ( ) - 1 ( event Thread i lSet &cap; eventThreadListTemp . get ( j ) . lSet ) = &Phi; , by eventThread iadd in eventThreadListTemp, make i=i+1, turn (2);
Otherwise eventThreadListTemp is added in layer (22), re-create an EventThreadList example eventThreadListTemp, make i=i+1, turn (2);
So far, can obtain a set layer who divides by level, wherein executed in parallel is wanted in all set in each eventThreadList, but between each eventThreadList, is serial successively.In the runSeq of sequence chart () function, carry out the thread of these set.
(3) based on type, two set add suitable sequence
In gathering to type two, existing event partial ordering set adds suitable sequence relation, makes in the time that event sets is carried out to topological sorting, not only can observe its existing order of occurrence, also can take into account the semanteme of the type expression of event place message.
Two message are all asynchronous messages, what no matter this message represented is operation or signal, after reception event occurs, capital obtains the message at its place, and open up a new thread and carry out the operation that message represents or carry out signal processing, therefore the order of incomparable event is unimportant between asynchronous message, because not order guarantee of the execution of thread itself, so only need add suitable sequence to relating to the event of synchronization message.
Specifically be implemented as follows:
Make L={l 0, l 1..., l n-1, l ibe i+1 article of lifeline, L represents the set of all lifelines in the type two set, uses
(1) make i=0;
(2) obtain l ion the transmission event sets of all synchronization messages! M;
(3) from! In M, obtain a transmission event! m j;
(4) because synchronization message mean, must wait for that this message is finished, the object that this lifeline represents could be processed next event, therefore will be by with its place same lifeline and betide! m jafter event be all placed in m jafter, and add partial ordering set;
(5) repeat (3) (4) until traveled through! M;
(6) make i=i+1, if i < is n, proceed to (2); Otherwise finish.
(4) type two set are converted to hierarchy chart
For representing conveniently, event node to be defined as follows:
event=(msgEndType,msg,guard,nextEvent,nextLayerEvent,
parentEvent,observation,constraint)
MsgEndType: be an enumerated variable, represent that this event is a transmission event or reception event, msgEndType ∈ { SendEvent, ReceiveEvent};
Msg: the message that represents place;
Guard: represent the state invariant before this event, when just occurring for this event of true;
NextEvent: the next event that represents current layer event;
NextLayerEvent: represent the next event in the control focus taking it as initiation event;
ParentEvent: the initiation event that represents the control focus at its place;
Observation: being illustrated in this event place has a TimeObservation or DurationObservation, if observation.firstevent=true, recording events in the time entering event, otherwise in the time exiting this event writing time;
Sequence chart in Fig. 5 can be converted to the hierarchy chart in Fig. 6.
Constraint: being illustrated in this event place has a time-constrain or duration constraints;
(1) make l=1, obtain the event of l layer: all is not directly or indirectly the event causing by controlling the message that focus sends;
(2) event of l layer is carried out to topological sorting, obtain a totally ordered set epSet={e 0, e 1..., e m-1, wherein e i.parentEvent=null, e i.nextEvent=e i+1, (0≤i < m-1), e m-1.nextEvent=null, make j=0;
(3) if epSet.e jbe that certain controls initiation event of focus, start to enter l+1 layer, obtain all message of directly or indirectly being sent by this control focus and the event that causes; These events are carried out to topological sorting and obtain a totally ordered set eqSet={e 0, e 1..., e n-1and make epSet.e j.nextLayerEvent=epSet.e 0, eqSet.e 0.parentEvent=epSet.e j;
(4) otherwise, make e k=e j.nextEvent,
(41) if e kunequal to null, makes e j=e k, turn (3);
(42) otherwise start to recall, make e k=e j.parentEvent;
(421) if e k=null, finishes;
Otherwise make e (422) k=e k.nextEvent, turn (41).
(5) writing time
First all time observations, duration are observed to all instantiations and put into the observation territory of the event being observed.Because time-constrain and duration constraints also need observing time, therefore they are put into the observation territory of retrained event.Specifically be implemented as follows:
(1) obtain all time observations, be that each time observation creates an example according to the record value in XMI file, and put it into the observation territory of the event of being observed.
(2) obtaining all duration observation, is that each duration observation creates an example according to the record value in XMI file; Associated two events of duration observation are put into this example in the observation territory of these two events.
(3) obtaining all time-constrains, is that each time-constrain creates an example according to the record value in XMI file, in the constraint territory of event that is subject to its constraint, inserts this example.
(4) obtaining all duration constraints, is that each duration constraints creates an example according to the record value in XMI file, in the constraint territory of two events that is subject to its constraint, inserts this example.
Introduce below
Void sendEventRecord (Observation observation, Constraint constraint) and void receiveEventRecord () (Observation observation, Constraint constraint) be writing time how.
Taking the former as example, being specifically implemented as follows of writing time:
(1) if observation=null turns (5);
(2), if observation unequal to is null, judge the type of observation;
(3) if observation is time observation type,
(31) if observation.firstEvent=true obtains system time t, and make observation.time=t;
Otherwise in the time exiting this function, obtain system time t, and make observation.time=t (32).
(4) if observation is duration observation type,
(41) if observation.firstEvent[0]=true, obtains system time t, and makes observation.startTime=t;
Otherwise in the time exiting this function, obtain system time t, and make observation.startTime=t (42).
(5) if constraint=null, interocclusal record while not carrying out;
(5) if constraint is time-constrain type,
(51) if constraint.firstEvent=true obtains system time t, and make constraint.time=t;
Otherwise in the time exiting this function, obtain system time t, and make constraint.time=t (52).
(6) if constraint is duration constraints type,
(61) if costraint.firstEvent[0]=true, obtains system time t, and makes observation.startTime=t;
Otherwise in the time exiting this function, obtain system time t, and make constraint.startTime=t (62).
(6) change event sequence hierarchy chart
(1) read the 1st event of the 1st layer;
(2) if event.guard=false turns (52);
(3) if event.msgEndType=SendEvent, the time of recording transmission event by sendEventRecord ();
(4) if event.msgEndType=RecieveEvent, the time that uses receiveEventRecord () to record reception event, obtain a message by msg=event.msg, make destination object resolve and carry out this msg,
(41) if msg is synchronization message, resolve this msg and obtain operation name and parameter, make destination object carry out this and operate corresponding function;
(42) if msg is asynchronous message,
(421) if msg represents is operation, resolves this msg and obtain operation name and parameter, opening a new thread and carry out this and operate corresponding function;
(422) be signal if msg represents, resolve this msg to obtain the type of this signal, search the Reception types of elements in the affiliated class of object that receives this signal, obtaining first parameter is the Reception types of elements of this signal type, this signal is transferred to the function processing of its generation, and open a new thread execution it.
(43) if msg creates message, obtain the additional numerical value of its associated msg, create an object and import these values into constructed fuction as parameter by new;
(44) if destroy message, carry out releasing memory by delete;
(45) if reply message, do not process.
(5) make eventN=event.nextLayerEvent,
(51) if eventN unequal to is null, make event=eventN, turn (2);
(52) otherwise make eventN=event.nextEvent,
(521) if eventN unequal to is null, make event=eventN, turn (2);
Otherwise make eventN=event.parentEvent (522); If eventN=null, finishes; Otherwise (52).

Claims (1)

1. an emulation mode for real time embedded system, is characterized in that the step that the method comprises is:
Step 1) is read in the uml model of preserving based on XMI form from disk file:
Described uml model comprises uml class graph model, UML sequence chart model; Described uml class graph model is the model of the class in descriptive system and the relation between them; Uml class graph model comprises following UML standard component: bag element, dvielement, interface element, data type element, basic data type element, enumeration element, signal element, comment element, and above-mentioned element is the maximum unit that uml class graph model is converted to C++ code; Described UML sequence chart model is that sending and receiving order by message between description object is to show the model of dynamic cooperative between multiple objects; UML sequence chart model comprises following UML standard component: interactive elements, and this element is that UML sequence chart model conversion is the maximum unit of C++ code; Described XMI uses a kind of object-oriented of XML exchange metadata information to organize OMG standard language; Described XML a kind ofly makes it have structural extend markup language for electroactive marker son file;
Step 2) element in uml model is divided in element class diagram set and sequence chart element set;
Step 21) obtain all elements that uml model comprises;
Step 22) if wrap element, dvielement, interface element, data type element, basic data type element, enumeration element, signal element, comment element, added element class diagram set;
Step 23) if interactive elements adds sequence chart element set;
The uml class graph model of the real time embedded system for the treatment of emulation is converted to C++ code by step 3);
Step 31) in the time also there is non-switched element class diagram in element class diagram set, read a non-switched element class diagram; Otherwise go to step 4);
Step 32) if current element class diagram is bag element, generate a .h file, state therein a NameSpace .h filename and NameSpace name are this element term;
Step 33) if current element class diagram is dvielement, generate a .h file and a .cpp file, this element is converted to a class in C++, go to step 310);
Step 34) if current element class diagram is interface element, generate a .h file and a .cpp file, the open method that this element is converted in C++ is all abstract class of pure virtual function, goes to step 310);
Step 35) if current element class diagram is data type element, generate a .h file and a .cpp file, this element is converted to a class in C++, go to step 310);
Step 36) if current element class diagram is fundamental type element, do not process;
Step 37) if current element class diagram is signal element, generate a .h file and a .cpp file, this element is converted to a class in C++, go to step 310);
Step 38) if current element class diagram is enumeration element, generate a .h file, enumerate, go to step 31 for one that this element is converted in C++);
Step 39) if current element class diagram is comment element, generate a C++ annotation, go to step 31);
Step 310) obtain the element that current element class diagram relies on, the header file title of the element relying on is comprised to the header file into currentElement, and use its NameSpace;
Step 311) obtain the element that current element class diagram is had to dependence, in the corresponding class of currentElement, the corresponding class that relies on element is made as to friendly metaclass, the header file title of the element relying on is comprised to the header file into currentElement;
Step 312) obtain the extensive all elements of current element class diagram, make currentElement public inheritance they; The header file title of these elements is comprised into current header file, and use its NameSpace;
Step 313) obtain current element class diagram by association, paradigmatic relation, the associated element of syntagmatic, according to associated multiplicity and observability suitable add a member variable, before variable, add one " * "; The header file title of associated element is comprised into current header file, and use its NameSpace;
Step 314) obtain the nested type element of current element class diagram inside and add element class diagram set, go to step 31);
Step 4) is C++ code by the UML sequence chart model conversion of the real time embedded system for the treatment of emulation;
Step 41) be temporal expression, time interval, duration interval, time observation, duration observation, time-constrain, a class of the each generation of these UML element types of duration constraints, and in the generation class of time-constrain and duration constraints, add a Boolean function for judging whether satisfied constraint of time;
Step 42) in the time that sequence chart element set also exists non-switched sequence chart element, read a non-switched sequence chart element; Otherwise go to step 5);
Step 43) current sequence figure element is decomposed into by time observation element, duration observation element, time-constrain element, duration constraints element, state invariant, controls the mutual fragment that focus element and message element form;
Step 431) precondition of current sequence figure element and postcondition are converted to and are asserted, and be placed on front position and the rearmost position of current sequence figure element entrance function;
Step 432) run into mutual use element, the .h file of specified mutual generation class is comprised in the .h file of current generation class; Create the object of a specified mutual generation class, using the object associated lifeline that uses alternately covering and the message that need to import into as entrance function parameter; The entrance function of allocating object;
Step 433) run into continuous types of elements, according to its title and setting, alt or seq combination are coupled together alternately;
Step 434) run into common region types of elements, all partial order sequences of the event sets it directly being comprised are deleted from the partial ordering set of sequence chart;
Step 435) run into combined fragment types of elements, decompose it;
Step 4351) if interactive operation symbol is alt, is illustrated in current combined fragment and has at the most an interactive operation territory to carry out; Each Operand is translated as to a conditional statement, the guard condition of Operand is converted to conditional expression;
Step 4352) if interactive operation symbol is opt, represent a kind of optional behavior, interactive operation territory is converted to a conditional statement, the guard condition of operation domain is converted to conditional expression;
Step 4353) if interactive operation symbol is break, transfer interactive operation territory to conditional branch statements, the guard condition in interactive operation territory is converted to conditional expression, last sentence of this conditional branch statements piece is break statement;
Step 4354) if interactive operation symbol is par, represent a kind of parallel behavior, each interactive operation territory is converted to a thread function;
Step 4355) if interactive operation symbol is seq, do not process;
Step 4356) if interactive operation symbol is loop, be converted to loop statement, the guard condition in interactive operation territory is converted to conditional expression;
Step 4357) if interactive operation symbol is critical, be converted into critical section;
Step 44) event sets is divided;
Step 441) if type three is gathered, divide event sets, make the each set after dividing become type two set; Then according to the related lifeline of these event sets, they are divided to level, the event sets executed in parallel of every one deck, and set between level keeps Serial Relation,, after upper strata event sets is finished, the event sets of lower one deck starts to carry out; Described type two set refer to that the event sets of sequence chart is partial ordering relation, and for any two message m sg1 and msg2, msg1 has at least an event to compare with the event of msg2; Described type three set refer to that the event sets of sequence chart at least can be divided into two set setA, setB, and for any message msgB in any message msgA and SetB in setA, the event of msgA and the event of msgB cannot compare;
Step 442) if type two gather, add suitable sequence relation to existing partial ordering set, make afterwards, in the time that event sets is carried out to topological sorting, not only will to observe its existing order of occurrence, also will consider the semanteme that the type of the message at event place is expressed;
Step 45) transfer the each event sets after dividing to hierarchy chart, in figure, node is event; Described hierarchy chart refers to according to controlling focus event sets is divided into different levels, in the time not occurring controlling focus, be the 1st layer, often run into one and control focus, event all can increase one deck, event under the same control focus of every layer from left to right successively sorts by occurring, and the event in every layer can be converted to the specific implementation of the associated message of its father node;
Step 46) all time observations, duration observation, time-constrain, duration constraints element are put into corresponding event;
Step 47) state invariant element is converted to and the condition of asserting of its next event in same lifeline;
Step 48) hierarchy chart is converted to C++ code: a time of origin that sends function and receiver function and be used for respectively recording transmission event and the event of reception is provided, when each asynchronous message is received, can open a new thread and carry out this message, the transcode of each event can write in the corresponding function of message of his father's Node Events association;
Step 49) entrance function using the transcode of ground floor event as this sequence chart element calls the Boolean function of all time-constrains and duration constraints example print result in this entrance function; Go to step 42);
Step 5) is C++ code by Simulink Coder by the Simulink model conversion of the real time embedded system for the treatment of emulation; The call back function that uses multimedia timer, advances its emulation with the frequency of fixing; Described Simulink model is to use Simulink to carry out the model of modeling gained; Affiliated Simulink is a kind of data stream figure programming language tools for modeling, emulation and analysis multiple domain dynamic system; Described Simulink Coder a kind ofly can and carry out the instrument of C/C++ from Simulink model generation;
Step 6) code merges: in the C++ code of being changed by Simulink Coder, contain input parameter structure, output parameter structure, initialization function and stop function; The code place changing in the operation of application <<SimCode>GreatT .GreaT.GT, the parameter correspondence of operation is imported in corresponding Simulink model parameter, and called successively initialization function and stop function;
The C++ code that above step 7) Complied executing, step conversion is come, offers user result.
CN201410122430.0A 2014-03-28 2014-03-28 Simulation method of real-time embedded system Active CN103885816B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410122430.0A CN103885816B (en) 2014-03-28 2014-03-28 Simulation method of real-time embedded system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410122430.0A CN103885816B (en) 2014-03-28 2014-03-28 Simulation method of real-time embedded system

Publications (2)

Publication Number Publication Date
CN103885816A true CN103885816A (en) 2014-06-25
CN103885816B CN103885816B (en) 2017-01-25

Family

ID=50954726

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410122430.0A Active CN103885816B (en) 2014-03-28 2014-03-28 Simulation method of real-time embedded system

Country Status (1)

Country Link
CN (1) CN103885816B (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106020788A (en) * 2016-04-28 2016-10-12 齐鲁工业大学 Intelligent software programming method
CN106325860A (en) * 2016-08-16 2017-01-11 北京控制工程研究所 Automatic maintenance method for aerospace embedded software interface data
CN106503496A (en) * 2016-12-08 2017-03-15 合肥康捷信息科技有限公司 Replaced and the Python shell script anti-reversal methods for merging based on operation code
CN106648617A (en) * 2016-11-14 2017-05-10 南京大学 Extended UML2 sequence chart-based interrupt-drive system modeling method
CN109190281A (en) * 2018-09-19 2019-01-11 北京润科通用技术有限公司 A kind of multi-core DSP platform algorithm development method and device
CN111381757A (en) * 2020-03-11 2020-07-07 上海索辰信息科技有限公司 Timing diagram activity callback processing system and method
CN111596901A (en) * 2020-05-19 2020-08-28 西安电子科技大学 C + + code generation method of unmanned aerial vehicle flight control system based on module definition diagram
CN112579073A (en) * 2020-12-25 2021-03-30 深圳市优必选科技股份有限公司 Code conversion method and device, electronic equipment and storage medium
CN113590129A (en) * 2021-07-17 2021-11-02 西北工业大学 Code automatic generation method based on synchronous reaction type component
CN116991373A (en) * 2023-09-27 2023-11-03 杭州华望系统科技有限公司 Semantic analysis and simulation system of sequence diagram model

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1996237A (en) * 2006-12-20 2007-07-11 浙江大学 Modeling method for embedded type real-time operating system based on model
WO2010006245A1 (en) * 2008-07-10 2010-01-14 Mentor Graphics Corporation Controlling real time during embedded system development
CN103020382A (en) * 2012-12-27 2013-04-03 北京仿真中心 BOM-based multi-instance polymerization simulation modeling method
CN103049301A (en) * 2012-12-27 2013-04-17 北京仿真中心 Multi-instance aggregation simulation modeling system on basis of BOM (basic object model)
CN103605556A (en) * 2013-10-23 2014-02-26 中国运载火箭技术研究院 Virtual test subject integrally-constructing system and method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1996237A (en) * 2006-12-20 2007-07-11 浙江大学 Modeling method for embedded type real-time operating system based on model
WO2010006245A1 (en) * 2008-07-10 2010-01-14 Mentor Graphics Corporation Controlling real time during embedded system development
CN103020382A (en) * 2012-12-27 2013-04-03 北京仿真中心 BOM-based multi-instance polymerization simulation modeling method
CN103049301A (en) * 2012-12-27 2013-04-17 北京仿真中心 Multi-instance aggregation simulation modeling system on basis of BOM (basic object model)
CN103605556A (en) * 2013-10-23 2014-02-26 中国运载火箭技术研究院 Virtual test subject integrally-constructing system and method

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王林章等: "设计模式指导的软件分簇方法", 《中国科学:信息科学》 *

Cited By (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106020788A (en) * 2016-04-28 2016-10-12 齐鲁工业大学 Intelligent software programming method
CN106325860A (en) * 2016-08-16 2017-01-11 北京控制工程研究所 Automatic maintenance method for aerospace embedded software interface data
CN106325860B (en) * 2016-08-16 2019-11-12 北京控制工程研究所 A kind of automated maintenance method of space flight embedded software interface data
CN106648617A (en) * 2016-11-14 2017-05-10 南京大学 Extended UML2 sequence chart-based interrupt-drive system modeling method
CN106648617B (en) * 2016-11-14 2019-10-15 南京大学 A kind of interrupt-driven system modeling method of the UML2 sequence chart based on extension
CN106503496A (en) * 2016-12-08 2017-03-15 合肥康捷信息科技有限公司 Replaced and the Python shell script anti-reversal methods for merging based on operation code
CN106503496B (en) * 2016-12-08 2019-03-19 合肥康捷信息科技有限公司 Based on operation code replacement and combined Python shell script anti-reversal method
CN109190281A (en) * 2018-09-19 2019-01-11 北京润科通用技术有限公司 A kind of multi-core DSP platform algorithm development method and device
CN111381757A (en) * 2020-03-11 2020-07-07 上海索辰信息科技有限公司 Timing diagram activity callback processing system and method
CN111596901A (en) * 2020-05-19 2020-08-28 西安电子科技大学 C + + code generation method of unmanned aerial vehicle flight control system based on module definition diagram
CN111596901B (en) * 2020-05-19 2022-12-02 西安电子科技大学 C + + code generation method of unmanned aerial vehicle flight control system based on module definition diagram
CN112579073A (en) * 2020-12-25 2021-03-30 深圳市优必选科技股份有限公司 Code conversion method and device, electronic equipment and storage medium
CN112579073B (en) * 2020-12-25 2024-04-19 深圳市优必选科技股份有限公司 Code conversion method, device, electronic equipment and storage medium
CN113590129A (en) * 2021-07-17 2021-11-02 西北工业大学 Code automatic generation method based on synchronous reaction type component
CN113590129B (en) * 2021-07-17 2024-05-17 西北工业大学 Code automatic generation method based on synchronous reaction type component
CN116991373A (en) * 2023-09-27 2023-11-03 杭州华望系统科技有限公司 Semantic analysis and simulation system of sequence diagram model
CN116991373B (en) * 2023-09-27 2024-01-05 杭州华望系统科技有限公司 Semantic analysis and simulation system of sequence diagram model

Also Published As

Publication number Publication date
CN103885816B (en) 2017-01-25

Similar Documents

Publication Publication Date Title
CN103885816A (en) Simulation method of real-time embedded system
Whittle et al. Scenario modelling with aspects
Harel et al. Synthesis revisited: Generating statechart models from scenario-based requirements
Engels et al. Testing the consistency of dynamic UML diagrams
CN109739494B (en) Tree-LSTM-based API (application program interface) use code generation type recommendation method
US10684936B2 (en) Observer for simulation test and verification
CN105378658B (en) Automatic source code generates
Campos et al. Supporting the analysis of safety critical user interfaces: an exploration of three formal tools
CN110262794A (en) A kind of AADL behaviour expanding method and tool based on specification with description language
CN110109658B (en) ROS code generator based on formalized model and code generation method
Bowen et al. Formal models for user interface design artefacts
Liu et al. Formal methods for the re-engineering of computing systems: a comparison
Cárdenas et al. Asymmetric Cell-DEVS models with the Cadmium simulator
Jamont et al. Designing embedded collective systems: The DIAMOND multiagent method
Redell et al. The AIDA toolset for design and implementation analysis of distributed real-time control systems
Biermann et al. Independence analysis of firing and rule-based net transformations in reconfigurable object nets
CN105607990A (en) Null pointer crash mining method and device
Saeedloei et al. From scenarios to timed automata
Markopoulos On the expression of interaction properties within an interactor model
Makinen et al. An interactive approach for synthesizing UML statechart diagrams from sequence diagrams
CN104660697B (en) Based on Kepler scientific workflow Sensor Network service combining methods
Mathaikutty et al. Ewd: A metamodeling driven customizable multi-moc system modeling framework
US20090326908A1 (en) Simulation support method, computer-readable storage medium storing simulation support program, and simulation support apparatus
CN109614105A (en) A kind of Android application return stack state static simulation method of Starting mode sensitivity
Fränzle et al. Visual temporal logic as a rapid prototyping tool

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