The content of the invention
The present invention exemplary embodiment be to provide a kind of PLC program development approach and device, it can solve the problem that existingAbove mentioned problem existing for technology.
According to the exemplary embodiment of the present invention, there is provided a kind of PLC program development approach, it is characterised in that including:(A)Executable mathematical modeling corresponding with the logic control function of needing to realize is obtained, and emulation survey is carried out to the mathematical modelingExamination;(B) when the mathematical modeling passes through emulation testing, PLC program is generated based on the mathematical modeling.
Alternatively, the mathematical modeling is Stateflow models.
Alternatively, the mathematical modeling includes Stateflow master casts and one or more Stateflow submodulesType, wherein, the step of mathematical modeling progress emulation testing, is included:Emulation survey is carried out to the Stateflow master castsExamination;When the Stateflow master casts pass through emulation testing, one or more than one Stateflow submodel is enteredRow emulation testing.
Alternatively, the mathematical modeling includes Stateflow master casts and one or more Stateflow submodulesType, wherein, step (A) includes:Obtain one or more temporal logics corresponding with the logic control function of needing to realizeProposition;Temporal logic proposition generation Stateflow master casts based on acquisition, and the Stateflow master casts are imitatedTrue test;When the Stateflow master casts pass through emulation testing, temporal logic proposition based on acquisition and describedStateflow master casts generate one or more Stateflow submodels, and to it is one or more than oneStateflow submodels carry out emulation testing.
Alternatively, in step (B), based on the main program of Stateflow master casts generation PLC program, and it is based onOne or more subprograms of one or more than one Stateflow submodel generation PLC program.
Alternatively, methods described also includes:System testing is directly carried out to the PLC program of generation.
In accordance with an alternative illustrative embodiment of the present invention, there is provided a kind of PLC program development device, it is characterised in that including:Mathematical modeling acquiring unit, executable mathematical modeling corresponding with the logic control function of needing to realize is obtained, and to describedMathematical modeling carries out emulation testing;PLC program generation unit, when the mathematical modeling passes through emulation testing, based on the numberLearn model generation PLC program.
Alternatively, the mathematical modeling is Stateflow models.
Alternatively, the mathematical modeling includes Stateflow master casts and one or more Stateflow submodulesType, wherein, mathematical modeling acquiring unit carries out emulation testing to the Stateflow master casts;When the Stateflow main mouldsWhen type passes through emulation testing, mathematical modeling acquiring unit emulates to one or more than one Stateflow submodelTest.
Alternatively, the mathematical modeling includes Stateflow master casts and one or more Stateflow submodulesType, wherein, mathematical modeling acquiring unit includes:Acquiring unit, obtain corresponding one with the logic control function of needing to realizeOr more than one temporal logic proposition;Master cast generation unit, the temporal logic proposition generation Stateflow main moulds based on acquisitionType, and emulation testing is carried out to the Stateflow master casts;Submodel generation unit, when the Stateflow master casts lead toWhen crossing emulation testing, temporal logic proposition and the Stateflow master casts based on acquisition generate one or moreStateflow submodels, and emulation testing is carried out to one or more than one Stateflow submodel.
Alternatively, main program of the PLC program generation unit based on Stateflow master casts generation PLC program, and baseIn one or more subprograms of one or more than one Stateflow submodel generation PLC program.
Alternatively, described device also includes:System testing unit, system testing is directly carried out to the PLC program of generation.
In accordance with an alternative illustrative embodiment of the present invention, there is provided a kind of computer-readable recording medium, be stored with computerProgram, it is characterised in that the computer program is configured as making the computing device PLC program as described above of computer to openForwarding method.
In accordance with an alternative illustrative embodiment of the present invention, there is provided a kind of computer, it is characterised in that including:As described aboveComputer-readable recording medium;Processor, the computer program stored for performing the computer-readable recording medium.
PLC program development approach according to an exemplary embodiment of the present invention and device, it can avoid carrying out PLC program as far as possibleMistake be present in coding procedure according to which design document, so as to effectively reduce the mistake in the PLC program of generation.
By in terms of partly illustrating that present general inventive concept is other in following description and/or advantage, also oneDivide and will be apparent by description, or the implementation of present general inventive concept can be passed through and learnt.
Embodiment
Embodiments of the invention are reference will now be made in detail, the example of the embodiment is shown in the drawings, wherein, identical markNumber identical part is referred to all the time.The embodiment will be illustrated by referring to accompanying drawing below, to explain the present invention.
Fig. 2 shows the flow chart of PLC program development approach according to an exemplary embodiment of the present invention.
Reference picture 2, in step S10, executable mathematical modeling corresponding with the logic control function of needing to realize is obtained,And emulation testing is carried out to the mathematical modeling.Here, the mathematical modeling can be supported emulation testing and can be changedInto various types of mathematical modelings of PLC program.
Preferred exemplary is only used as, the mathematical modeling can be Stateflow models.
Further, as an example, the mathematical modeling may include Stateflow master casts and one or moreStateflow submodels.Here, Stateflow master casts can be used for the main program of generation PLC program, Stateflow submodelsSubprogram available for generation PLC program.It is also understood by those skilled in the art that the mathematical modeling also can only includeStateflow master casts.
Particularly, Stateflow models can be the graphical representation of finite state machine, that is, control logicIt can be described by graphical object Stateflow figures, also, Stateflow figures support the hierarchical description of control logic.Such as Fig. 3Shown, the state in Stateflow can be with layer representation, and state A is a parent status, includes sub- state B1 and B2;State B2Including sub- state C1, C2, C3;State C1 includes sub- state D1, D2;State C3 includes sub- state D3 and D4.State B1's and B2Relation can be and relation either or relation.If state B1 and B2 are or relation, then it represents that two states can not be simultaneouslyIt is active, i.e., if state B1 is active, then state B2 is now inactive, and vice versa.Further, if state B1It is active, state B2 all sub- state C1, C2, C3, D1, D2, D3 and D4 can not be performed.Here, it is corresponding with parent status AStateflow figures can be used as Stateflow master casts, Stateflow figures corresponding with the sub- state of last layer can be made respectivelyFor a Stateflow submodel.Therefore, the Hierarchical Design to PLC program can be realized by Stateflow models.
As an example, when the mathematical modeling is Stateflow models, first Stateflow master casts can be imitatedTrue test;Emulation testing is carried out when the Stateflow master casts pass through emulation testing, then to Stateflow submodels.
As an example, it can directly read to realize the logic control function of needs and generate executableStateflow models.As another example, also can first read to realize the logic control function of needs and generate one orMore than one temporal logic proposition, the temporal logic proposition for being then based on reading generate Stateflow models.Below in conjunction withFig. 4 describes specific exemplary embodiment.
Fig. 4 shows the flow of acquisition mathematical modeling according to an exemplary embodiment of the present invention and the method for carrying out emulation testingFigure.
Reference picture 4, in step S101, obtain it is corresponding with the logic control function that needs are realized one or more whenState logical proposition.
In the prior art, easily there is implication, ambiguous problem in the PLC program specification of character type, andPLC program specification according to an exemplary embodiment of the present invention based on tense logic language is mathematical form, has letterIt is clean, unambiguously the advantages of.
As an example, the temporal logic proposition obtained can be the tense logic language embedded by Stateflow instrumentsIt is encoded.
In step S102, the temporal logic proposition based on acquisition generates Stateflow master casts, and to describedStateflow master casts carry out emulation testing.
In step S103, when the Stateflow master casts pass through emulation testing, the temporal logic proposition based on acquisitionGenerate one or more Stateflow submodels with the Stateflow master casts, and to it is one or more than oneStateflow submodels carry out emulation testing.Particularly, can be sequentially generated and upper one according to the temporal logic proposition of acquisitionStateflow submodels corresponding to sub- state in layer Stateflow models (being initially Stateflow master casts).
Fig. 2 is returned, in step S20, when the mathematical modeling passes through emulation testing, is generated based on the mathematical modelingPLC program.Here, the PLC program generated can realize the logic control function of needing to realize when executed.
As an example, when the mathematical modeling includes Stateflow master casts and one or more StateflowDuring model, if Stateflow master casts and whole Stateflow submodels can determine that the number by emulation testingLearn model and pass through emulation testing;When the mathematical modeling only includes Stateflow master casts, if Stateflow master castsBy emulation testing, then it can determine that the mathematical modeling passes through emulation testing.
As an example, when the simulation results of the mathematical modeling suit the requirements the requirement of the logic control function of realizationWhen, it may be determined that the mathematical modeling passes through emulation testing.For example, may be in response to the operation of developer, realize as neededThe requirement of logic control function pre-sets emulation testing and needs the simulation results reached, when imitating for the mathematical modelingWhen true test result is consistent with the simulation results for needing to reach, then it can determine that the mathematical modeling is surveyed by emulatingExamination.
As an example, when the mathematical modeling is Stateflow models, Stateflow master casts generation PLC can be based onThe main program of program, and based on each subprogram of each Stateflow submodels generation PLC program.
As an example, PLC program development approach according to an exemplary embodiment of the present invention may also include:When the mathematical moduloWhen type is not over emulation testing, the simulation results of the mathematical modeling are shown, in order to which developer surveys with reference to emulationTest result is completed to adjust corresponding with needing the logic control function realized temporal logic proposition and/or mathematical modeling, adjustmentAfter return again to and perform step S10.
In addition, as an example, PLC program development approach according to an exemplary embodiment of the present invention may also include:To generationPLC program directly carry out system testing.
In the prior art, it will usually with reference to the programming text generated in Outline Design step and detailed design stepShelves carry out PLC program coding, on the one hand, the form of existing programming document is not supported to test, if programming is literaryShelves are inaccurate, then the PLC program subsequently write will be caused inaccurate;On the other hand, the form of existing programming documentDo not support to automatically generate PLC program.And according to the exemplary embodiment of the present invention, in Outline Design step and detailed design stepWhat is generated is executable mathematical modeling, on the one hand, emulation testing can be supported, to avoid just drawing before PLC program encodesEnter mistake, so as to reduce the mistake in PLC program coding;On the other hand, it would be preferable to support automatically generate PLC program.
Fig. 5 shows PLC program development mode according to an exemplary embodiment of the present invention.As shown in figure 5, according to the present invention'sExemplary embodiment can be just tested the mathematical modeling of design in Outline Design step and detailed design step, is only existedTest can just perform PLC program after and encode, therefore, it is possible to effectively reduce the mistake in the PLC program of generation, then,, can execution unit test, integration testing, system testing and Acceptance Test successively after PLC program end-of-encode.Show as anotherExample, also can directly carry out system testing, without unit testing to be carried out and integration testing after PLC program end-of-encode.
Below, according to an exemplary embodiment of the present invention be based on is described by taking crossing traffic light systems as an exampleThe PLC program development approach of Stateflow models.
Crossing traffic light systems are a kind of guiding traffic control signal system of the pedestrains safety by crossing.Fig. 6 showsThe schematic diagram of crossing traffic lights is gone out, vehicle travels along East and West direction, and pedestrian can only be in north and south upwardly through road.In thingUpwards, there are three kinds of signal lamps of red, yellow, and green;On north-south, there are red, green two kinds of signal lamps, pass through in addition, being additionally provided with pedestrianThe request button of road.
1st, the demand for control of the system is as follows:
1) when unmanned walking on zebra stripes, transmeridional green light, the when red in north-south, vehicle can pass through at a high speedCrossing, now, pedestrian's no thoroughfare road;
2) when pedestrian wants to pass through road, press a call button, after 30 seconds, transmeridional green light goes out, and then amber light is bright,Driver is reminded to slow down and no thoroughfare zebra stripes, after 10 seconds, transmeridional amber light goes out, then when red, reminds driver to stop carBeyond zebra stripes, after 5 seconds, the red light in north-south goes out, then green light, and now, pedestrian can be with safety zebra stripes;
3) green light in north-south 15 seconds, then when red reminds the pedestrian on road quickly through zebra stripes, and is in spotPedestrian outside horse line can not be by the way that after 5 seconds, transmeridional red light goes out, then green light.
2nd, program specification
First, correlated variables is defined, asks button to be represented by event E by road, signal lamp is bright to be represented by P (x, y), itsIn, x expressions direction, x ∈ { e, n }, e expression east-west direction, n expression North and South directions, the color of y expression signal lamps, y ∈ g, y,R }, g represents green, and y represents yellow, and r represents red.Based on above-mentioned variable, the traffic based on tense logic language is illustrated belowThe formalized description of lamp system demand for control (that is, it needs to the logic control function of realizing):
1)
2)
In above-mentioned proposition P2, P3 and P4, migration is 30 seconds, 10 seconds and 5 seconds respectively at the time of generation.
3)
In above-mentioned proposition P5 and P6, migration is 15 seconds and 5 seconds respectively at the time of generation.
Because the signal lamp of somewhat different color can not be simultaneously bright, so being also implied with following two lives in program requirementsTopic:
On this basis, by joint proposition P2, P3, P4, P5 and P6, proposition P9 can be obtained, at the time of migration occursIt is 65 seconds.
By joint proposition P4, P5 and P6, proposition P10 can be obtained, migration is 25 seconds, equally, proposition at the time of generationP11 can be combined to obtain by proposition P2, P3 and P4, and migration is 45 seconds at the time of generation.
For the ease of understanding above-mentioned temporal logic proposition, as an example, under represent 6 kinds of temporal logic symbols:
Table 1
3rd, hierarchical design and test
Stateflow master casts can obtain according to proposition P1, P2 and P9, as shown in fig. 7, wherein, state A1 shows thingTo green light, north-south when red;State A2 is a parent status, includes state B1 and B2.Here, state variable temp is setCome whether test status are active, variable data represents to ask the state of button.
Then, emulation testing is carried out to obtained Stateflow master casts, in emulation testing, it is assumed that request button is everyBy next time, Fig. 8 shows the simulation results in 90 seconds of Stateflow master casts, and state A2 is activated first within 80 seconds, thisIt can be worth to from variable temp, after 65 seconds, variable eg and nr value is changed into 1, this instruction East and West direction green light, north-south when red.As can be seen that Stateflow master casts (that is, father's layer designs) are consistent with program specification, meet logic control requirement, fromAnd pass through emulation testing.
Next, generation Stateflow submodels, the sublayer design of the present embodiment includes two relations as the son with relationState B1 and B2, sub- state B1 detailed design can be obtained by proposition P2, P3 and P10, wherein, state C1, C2 and C3 difference tableShow the state of East and West direction green light, amber light and red light.Correspondingly, sub- state B2 detailed design can be obtained by proposition P5 and P11, itsIn, state C4 and C5 represent the state of north-south red light and green light respectively.Fig. 9 shows the signal of two Stateflow submodelsFigure.
Then, two obtained Stateflow submodels are carried out with emulation testing, Figure 10 shows that sublayer designs in 80 secondsThe simulation results, variate-value eg, ey and er be changed into 1 successively, and this indicates transmeridional green light, amber light and red light point successivelyIt is bright;Equally, the red light in north-south, green light are lighted in order;It is same that the north-south same time only lights signal lamp, an East and West directionTime only lights a signal lamp;In addition, the switch time of each lamp is consistent with program specification, meet logic controlIt is required that this explanation Stateflow submodel (that is, sublayer designs) is also rational.
4th, PLC program is generated based on Stateflow models
The PLC program of generation is made up of a main program OB1, three subprograms FC1, FC2 and FC3.Master shown in Figure 11Program OB1 is that the Stateflow master casts according to Fig. 7 generate, wherein, temporary variable temp need by FC1 and FC2 LaiInstead of.Subprogram shown in Figure 12 and Figure 13 is Stateflow corresponding with sub- state B1 and B2 according to Fig. 9 respectivelyModel generation.Subprogram FC3 shown in Figure 14 is used for exporting the end-state of the signal lamp within a scan period.
In addition, can also test as desired the PLC program of generation, the present invention will not be repeated here.
Figure 15 shows the block diagram of PLC program development device according to an exemplary embodiment of the present invention.As shown in figure 15, according toThe PLC program development device of exemplary embodiment of the present includes:Mathematical modeling acquiring unit 10 and PLC program generation unit20。
Particularly, mathematical modeling acquiring unit 10 is used to obtain hold corresponding with the logic control function of needing to realizeCapable mathematical modeling, and emulation testing is carried out to the mathematical modeling.
As an example, the mathematical modeling can be Stateflow models.
As an example, the mathematical modeling may include Stateflow master casts and one or more StateflowModel, wherein, mathematical modeling acquiring unit 10 can carry out emulation testing to the Stateflow master casts;When describedWhen Stateflow master casts pass through emulation testing, mathematical modeling acquiring unit 10 is to one or more than one StateflowSubmodel carries out emulation testing.
PLC program generation unit 20 is used for when the mathematical modeling passes through emulation testing, is given birth to based on the mathematical modelingInto PLC program.
As an example, PLC program generation unit 20 can generate the main journey of PLC program based on the Stateflow master castsSequence, and based on one or more subprograms of one or more than one Stateflow submodel generation PLC program.
Figure 16 shows the block diagram of mathematical modeling acquiring unit according to an exemplary embodiment of the present invention.Here, the mathematicsModel may include Stateflow master casts and one or more Stateflow submodels, as shown in figure 16, mathematical modelingAcquiring unit 10 may include:Acquiring unit 101, master cast generation unit 102 and submodel generation unit 103.
Particularly, acquiring unit 101 is used to obtain one or one corresponding with the logic control function of needing to realizeAbove temporal logic proposition.
Master cast generation unit 102 is used for the temporal logic proposition generation Stateflow master casts based on acquisition, and to instituteState Stateflow master casts and carry out emulation testing.
Submodel generation unit 103 be used for when the Stateflow master casts pass through emulation testing, based on acquisition whenState logical proposition and the Stateflow master casts generate one or more Stateflow submodels, and to oneOr more than one Stateflow submodel carries out emulation testing.
As an example, PLC program development device according to an exemplary embodiment of the present invention may also include:System testing unit(not shown).System testing unit is used to directly carry out system testing to the PLC program of generation.
It should be understood that the specific implementation of PLC program development device according to an exemplary embodiment of the present invention can refer toRealize, will not be repeated here with reference to the related specific implementation that Fig. 1-Figure 14 is described.
Computer program is had according to the computer-readable recording medium storage of the exemplary embodiment of the present invention, wherein, instituteState the PLC program exploitation side for the computing device any of the above-described exemplary embodiments that computer program can be configured as making computerMethod.
It may include according to the computer of the exemplary embodiment of the present invention:Computer described in above-mentioned example embodiment canRead storage medium (not shown) and processor (not shown).
Processor is used to perform the computer program that the computer-readable recording medium is stored.
PLC program development approach according to an exemplary embodiment of the present invention and device, it can avoid carrying out PLC program as far as possibleMistake be present in coding procedure according to which design document, so as to effectively reduce the mistake in the PLC program of generation.
Moreover, it should be understood that the unit in PLC program development device according to an exemplary embodiment of the present invention can quiltRealize nextport hardware component NextPort and/or component software.Processing of the those skilled in the art according to performed by the unit of restriction, can exampleSuch as unit is realized using field programmable gate array (FPGA) or application specific integrated circuit (ASIC).
In addition, PLC program development approach according to an exemplary embodiment of the present invention may be implemented as computer-readable noteComputer code in recording medium.Those skilled in the art can realize the computer generation according to the description to the above methodCode.The above method of the present invention is realized when the computer code is performed in a computer.
Although having show and described some exemplary embodiments of the present invention, it will be understood by those skilled in the art that, can be to these in the case where not departing from the principle of the invention that its scope is limited by claim and its equivalent and spiritEmbodiment is modified.