CN110908650A - Software rapid programming method based on state machine - Google Patents
Software rapid programming method based on state machine Download PDFInfo
- Publication number
- CN110908650A CN110908650A CN201910995549.1A CN201910995549A CN110908650A CN 110908650 A CN110908650 A CN 110908650A CN 201910995549 A CN201910995549 A CN 201910995549A CN 110908650 A CN110908650 A CN 110908650A
- Authority
- CN
- China
- Prior art keywords
- state
- point
- graph
- points
- software
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 21
- 238000010586 diagram Methods 0.000 claims abstract description 44
- 230000003213 activating effect Effects 0.000 claims abstract description 13
- 230000004913 activation Effects 0.000 claims description 4
- 238000011161 development Methods 0.000 abstract description 5
- 238000012545 processing Methods 0.000 description 6
- 230000006870 function Effects 0.000 description 5
- 230000009286 beneficial effect Effects 0.000 description 2
- 230000009471 action Effects 0.000 description 1
- 230000004075 alteration Effects 0.000 description 1
- 230000006399 behavior Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/34—Graphical or visual programming
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The invention relates to the technical field of software development and discloses a software rapid programming method based on a state machine, which comprises the following steps: constructing a resource (Res) consisting of a state diagram (graph) set and an interface (interface) set; creating a graph top instance of a state graph (graph) and initializing a starting point (point start) and an end point (point end) to be in an inactivated state; and creating a state diagram (graph) according to the state diagram (graph) relation specified by the resource (Res), and initializing all state points (points) to be in an inactivated state. The method has the advantages that the software programming mode can be effectively simplified and the programming problem can be successfully converted into the drawing problem by constructing the state diagram (graph) and the state point (point), acquiring the state value by activating the state point and calling out the code block from the state value screened by the state point. Therefore, the user does not need to face a large amount of codes any more during development, only needs to create a plurality of state diagrams, fills in a plurality of attributes and a few parts of code blocks to complete software programming.
Description
Technical Field
The invention relates to the technical field of software development, in particular to a software rapid programming method based on a state machine.
Background
Mathematically, a state machine is a directed graph that consists of a set of nodes and a set of corresponding transfer functions, and operates in response to a series of events. The state machine can be generalized to 4 elements: current state, condition, action, next state. In computer science, state machines are widely applied to modeling application behaviors, hardware circuit design, software engineering and the like, are already the core foundation of the information technology field, but the state machines are not applied to software programming at present.
In the technical field of software programming, a programming mode of code writing is basically adopted, an editor needs to store a large amount of codes and symbols, errors are easy to occur, the writing efficiency is low, and a convenient and concise software quick programming method is urgently needed.
Disclosure of Invention
Technical problem to be solved
Aiming at the defects of the prior art, the invention provides a software rapid programming method based on a state machine, which has the advantages of simple programming mode, high programming efficiency and the like and solves the problem of low efficiency of the existing programming mode.
(II) technical scheme
In order to realize the purposes of simple and convenient program mode and high programming efficiency, the invention provides the following technical scheme: a software rapid programming method based on a state machine is characterized by comprising the following steps:
1) constructing a resource (Res) consisting of a state diagram (graph) set and an interface (interface) set;
2) creating a graph top instance of a state graph (graph) and initializing a starting point (point start) and an end point (point end) to be in an inactivated state;
3) creating a state diagram (graph) according to the state diagram (graph) relation specified by the resource (Res), and initializing all state points (points) to be in an inactivated state;
4) activating a starting point (point start) of a graph top instance, and waiting for a working thread to execute the point;
5) a plurality of superior state points are to activate the current state points, and the return value of the code block is equal to the state value of the current state points;
6) the current state point outputs a logic value through a logic controller;
7) whether the output logic value is equal to one,
8) activating a state point;
9) canceling the activation state point;
10) after the corresponding state point is judged and activated by logic, the code block bound by the point is called;
11) the code block returns a result, and the result is the state value of the next state point needing to be activated;
12) program code of the required software is generated.
Preferably, the state diagram (graph) in step 1) includes a plurality of state points (points) and a connection set.
Preferably, the plurality of state points (points) are divided into a start point (point start), an end point (point), a state point (point), and an error handling point (error).
Preferably, the starting point (point start) and the end point (point end) constitute a graph top instance, and the state point (point) and the error handling point (error) constitute a graph top grr instance.
Preferably, the state point in step 3) is composed of a logic controller and a code block, and the output logic value in step 6) has only zero and two values.
Preferably, step 8) is executed when the output logic value in step 7) is equal to one, and step 9) is executed when the output logic value in step 7) is not equal to one.
Preferably, the code in the code block is provided by a set of interfaces (interfaces) in the resource (Res).
(III) advantageous effects
Compared with the prior art, the invention provides a software rapid programming method based on a state machine, which has the following beneficial effects:
1. according to the software rapid programming method based on the state machine, a state diagram (graph) and state points (points) are constructed, state values are obtained by activating the state points, and code blocks are called out through the state values screened by the state points, so that the software programming mode can be effectively simplified. Therefore, the user does not need to face a large amount of codes during development, and only needs to create a plurality of state diagrams, fill in a plurality of attributes and a few parts of code blocks to complete the development of the software.
2. According to the software rapid programming method based on the state machine, codes are generated by adopting a mode of constructing the state diagram, so that software editors do not need to spend a large amount of time to learn codes and programming grammar, and only need to construct the state diagram (graph) according to the needs of the software editors on the program, the logic of the state diagram is simpler and clearer, the state diagram is easier to understand, the programming difficulty and the learning difficulty of programming can be greatly reduced, and the purpose of reducing the programming difficulty is achieved.
Drawings
FIG. 1 is a schematic diagram of the resource (Res) structure of the present invention;
FIG. 2 is a schematic diagram of the state diagram (graph) according to the present invention;
FIG. 3 is a schematic diagram of the structure of a point of state (point) according to the present invention;
FIG. 4 is a flow chart of the operation of the state diagram (graph) of the present invention;
fig. 5 is a flow chart of the operation of the point of state (point) of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The first embodiment is as follows:
a software rapid programming method based on a state machine is characterized by comprising the following steps:
1) constructing a resource (Res) consisting of a state diagram (graph) set and an interface (interface) set;
2) creating a graph top instance of a state graph (graph) and initializing a starting point (point start) and an end point (point end) to be in an inactivated state;
3) creating a state diagram (graph) according to the state diagram (graph) relation specified by the resource (Res), and initializing all state points (points) to be in an inactivated state;
4) activating a starting point (point start) of a graph top instance, and waiting for a working thread to execute the point;
5) a plurality of superior state points are to activate the current state points, and the return value of the code block is equal to the state value of the current state points;
6) the current state point outputs a logic value through a logic controller;
7) whether the output logic value is equal to one,
8) activating a state point;
9) canceling the activation state point;
10) after the corresponding state point is judged and activated by logic, the code block bound by the point is called;
11) the code block returns a result, and the result is the state value of the next state point needing to be activated;
12) program code of the required software is generated.
The state diagram (graph) in the step 1) includes a plurality of state points (points) and a connection set, the connection is used for connecting the state points in the state diagram or the state points between the state diagrams, each state point is bound with a code block or a member function of res, each state point has a state value, the state points in the same state diagram cannot have the same state value, and each function or code block returns a state value for activating the subsequent state points.
The plurality of state points (point) are divided into a starting point (point start), an end point (point end), a state point (point) and an error processing point (error), the error processing point (error) is used for processing errors, the starting point (point start) of the graphtop is in an activated state when the program is started, a certain specified point of the specified graphtmr is activated according to the connection relation configured by the user, and the system traverses the activated state point and calls the code bound by the point.
The starting point (point start) and the end point (point end) form a graph top instance, and the state point (point) and the error handling point (error) form a graph top instance.
The state point in the step 3) is composed of a logic controller and a code block, the output logic value in the step 6) is only zero and two values, and the logic controller is responsible for logic judgment and generally designates a logic relationship by a user.
Step 8) is executed when the output logic value is equal to one in step 7), and step 9) is executed when the output logic value is not equal to one in step 7).
The code in the code block is provided by a set of interfaces (interfaces) in the resource (Res).
The invention has the beneficial effects that: according to the software rapid programming method based on the state machine, a state diagram (graph) and state points (points) are constructed, state values are obtained by activating the state points, and code blocks are called out through the state values screened by the state points, so that the software programming mode can be effectively simplified. Therefore, a user does not need to face a large amount of codes during development, only needs to create a plurality of state diagrams, fills in a plurality of attributes and a few code blocks to complete the development of the software, and generates the codes by adopting a mode of constructing the state diagrams, so that software editors do not need to spend a large amount of time to learn codes and programming grammar, and only need to construct the state diagrams (graphs) according to the needs of the software editors to the programs, the logics of the state diagrams are simpler and clearer, the state diagrams are easier to understand, the programming difficulty and the learning difficulty can be greatly reduced, and the purpose of reducing the programming difficulty is achieved.
Typical cases are as follows:
a software rapid programming method based on a state machine is characterized by comprising the following steps:
1) constructing a resource (Res) consisting of a state diagram (graph) set and an interface (interface) set;
2) creating a graph top instance of a state graph (graph) and initializing a starting point (point start) and an end point (point end) to be in an inactivated state;
3) creating a state diagram (graph) according to the state diagram (graph) relation specified by the resource (Res), and initializing all state points (points) to be in an inactivated state;
4) activating a starting point (point start) of a graph top instance, and waiting for a working thread to execute the point;
5) a plurality of superior state points are to activate the current state points, and the return value of the code block is equal to the state value of the current state points;
6) the current state point outputs a logic value through a logic controller;
7) whether the output logic value is equal to one,
8) activating a state point;
9) canceling the activation state point;
10) after the corresponding state point is judged and activated by logic, the code block bound by the point is called;
11) the code block returns a result, and the result is the state value of the next state point needing to be activated;
12) program code of the required software is generated.
The state diagram (graph) in the step 1) includes a plurality of state points (points) and a connection set, the connection is used for connecting the state points in the state diagram or the state points between the state diagrams, each state point is bound with a code block or a member function of res, each state point has a state value, the state points in the same state diagram cannot have the same state value, and each function or code block returns a state value for activating the subsequent state points.
The plurality of state points (point) are divided into a starting point (point start), an end point (point end), a state point (point) and an error processing point (error), the error processing point (error) is used for processing errors, the starting point (point start) of the graphtop is in an activated state when the program is started, a certain specified point of the specified graphtmr is activated according to the connection relation configured by the user, and the system traverses the activated state point and calls the code bound by the point.
The starting point (point start) and the end point (point end) form a graph top instance, and the state point (point) and the error handling point (error) form a graph top instance.
The state point in the step 3) is composed of a logic controller and a code block, the output logic value in the step 6) is only zero and two values, and the logic controller is responsible for logic judgment and generally designates a logic relationship by a user.
Step 8) is executed when the output logic value is equal to one in step 7), and step 9) is executed when the output logic value is not equal to one in step 7).
The code in the code block is provided by a set of interfaces (interfaces) in the resource (Res).
Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that changes, modifications, substitutions and alterations can be made in these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.
Claims (7)
1. A software rapid programming method based on a state machine is characterized by comprising the following steps:
1) constructing a resource (Res) consisting of a state diagram (graph) set and an interface (interface) set;
2) creating a graph top instance of a state graph (graph) and initializing a starting point (point start) and an end point (point end) to be in an inactivated state;
3) creating a state diagram (graph) according to the state diagram (graph) relation specified by the resource (Res), and initializing all state points (points) to be in an inactivated state;
4) activating a starting point (point start) of a graph top instance, and waiting for a working thread to execute the point;
5) a plurality of superior state points are to activate the current state points, and the return value of the code block is equal to the state value of the current state points;
6) the current state point outputs a logic value through a logic controller;
7) whether the output logic value is equal to one,
8) activating a state point;
9) canceling the activation state point;
10) after the corresponding state point is judged and activated by logic, the code block bound by the point is called;
11) the code block returns a result, and the result is the state value of the next state point needing to be activated;
12) program code of the required software is generated.
2. The software rapid programming method based on the state machine according to claim 1, wherein the state diagram (graph) in the step 1) includes a plurality of state points (points) and a connection set.
3. The method as claimed in claim 2, wherein the plurality of state points (points) are divided into a starting point (point start), an ending point (point end), a state point (point) and an error handling point (error).
4. A software rapid programming method based on state machine according to claim 3, characterized in that the starting point (point start) and the end point (point end) form a graph top instance, and the state point (point) and the error handling point (error) form a graph top grr instance.
5. The method as claimed in claim 1, wherein the state point in step 3) is composed of a logic controller and a code block, and the output logic value in step 6) has only zero and two values.
6. The method as claimed in claim 1, wherein step 7) is performed when the output logic value is equal to one, and step 7) is performed when the output logic value is not equal to one, and step 9) is performed.
7. A state machine based software rapid programming method according to claim 5, characterized in that the code in the code block is provided by a set of interfaces (interfaces) in the resource (Res).
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910995549.1A CN110908650A (en) | 2019-10-18 | 2019-10-18 | Software rapid programming method based on state machine |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910995549.1A CN110908650A (en) | 2019-10-18 | 2019-10-18 | Software rapid programming method based on state machine |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110908650A true CN110908650A (en) | 2020-03-24 |
Family
ID=69815680
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910995549.1A Pending CN110908650A (en) | 2019-10-18 | 2019-10-18 | Software rapid programming method based on state machine |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110908650A (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1776625A (en) * | 2004-11-18 | 2006-05-24 | 国际商业机器公司 | Updating elements in a data storage facility using a predefined state machine and device thereof |
CN101196810A (en) * | 2006-12-08 | 2008-06-11 | 中颖电子(上海)有限公司 | Built-in equipment operation method |
CN101783979A (en) * | 2010-03-10 | 2010-07-21 | 华为技术有限公司 | Method, apparatus and system for registering passive optical network based on Ethernet |
CN104050087A (en) * | 2014-07-04 | 2014-09-17 | 东南大学 | Software architecture correctness verification method based on UML model |
CN109564530A (en) * | 2016-06-08 | 2019-04-02 | 谷歌有限责任公司 | The personal supplementary module for having the selectable state machine traversed is provided |
-
2019
- 2019-10-18 CN CN201910995549.1A patent/CN110908650A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1776625A (en) * | 2004-11-18 | 2006-05-24 | 国际商业机器公司 | Updating elements in a data storage facility using a predefined state machine and device thereof |
CN101196810A (en) * | 2006-12-08 | 2008-06-11 | 中颖电子(上海)有限公司 | Built-in equipment operation method |
CN101783979A (en) * | 2010-03-10 | 2010-07-21 | 华为技术有限公司 | Method, apparatus and system for registering passive optical network based on Ethernet |
CN104050087A (en) * | 2014-07-04 | 2014-09-17 | 东南大学 | Software architecture correctness verification method based on UML model |
CN109564530A (en) * | 2016-06-08 | 2019-04-02 | 谷歌有限责任公司 | The personal supplementary module for having the selectable state machine traversed is provided |
Non-Patent Citations (3)
Title |
---|
王欣: "基于状态机的移动终端应用软件设计", 《中国优秀硕士学位论文全文数据库 信息科技辑》, no. 04, pages 138 - 193 * |
范雄涛等: "基于有限状态机的 PLC 程序设计方法", 《电气技术》 * |
范雄涛等: "基于有限状态机的 PLC 程序设计方法", 《电气技术》, 15 February 2018 (2018-02-15), pages 1 - 3 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107203473A (en) | The automatization test system and method for automatic expansion interface test case | |
CN105608001A (en) | Test method and test platform based on background system service or interface | |
CN111611008A (en) | Software code packaging and deploying method, device, equipment and storage medium | |
CN110599341A (en) | Transaction calling method and system | |
CN107179982B (en) | Cross-process debugging method and device | |
CN110865854B (en) | Interface calling and arranging method supporting hot deployment | |
CN109857642B (en) | Blocking type debugging method and debugging tool for UI automation script | |
CN110968404A (en) | Equipment data processing method and device | |
CN117908868A (en) | Configuration system based on ore-grade system | |
CN110908650A (en) | Software rapid programming method based on state machine | |
CN109460193B (en) | IO processing method, device and terminal in storage system | |
WO2022257303A1 (en) | Method and apparatus for deploying deep learning system | |
CN115827121A (en) | Asynchronous simulation execution engine system and method based on graph elements | |
CN104536892A (en) | Software online debugging method and system | |
Frey et al. | “Safety automata”—A new specification language for the development of PLC safety applications | |
CN109710537B (en) | Intelligent automatic testing method and system | |
CN111596923B (en) | Haxe static link library construction method and device and electronic equipment | |
CN114675948A (en) | DAG data model dynamic scheduling method and system | |
CN111190725B (en) | Task processing method, device, storage medium and server | |
CN110389751B (en) | Data interface mock method applied to knowledge graph | |
CN113312247A (en) | Fault simulation method and system and test method of distributed system | |
CN113419775B (en) | Firmware configuration method, system, equipment and medium | |
CN112650573B (en) | Task scheduling method and device | |
WO2018137146A1 (en) | Graph configuration language transformation method and apparatus | |
CN111061467B (en) | Method for efficiently managing front-end engineering request module |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20200324 |