CN114461691A - State machine control method, device, electronic device and storage medium - Google Patents
State machine control method, device, electronic device and storage medium Download PDFInfo
- Publication number
- CN114461691A CN114461691A CN202210125108.8A CN202210125108A CN114461691A CN 114461691 A CN114461691 A CN 114461691A CN 202210125108 A CN202210125108 A CN 202210125108A CN 114461691 A CN114461691 A CN 114461691A
- Authority
- CN
- China
- Prior art keywords
- state
- event
- state machine
- processed
- state transition
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2457—Query processing with adaptation to user needs
- G06F16/24575—Query processing with adaptation to user needs using context
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/25—Integrating or interfacing systems involving database management systems
- G06F16/252—Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N20/00—Machine learning
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Artificial Intelligence (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Evolutionary Computation (AREA)
- Medical Informatics (AREA)
- Computational Linguistics (AREA)
- Computing Systems (AREA)
- Mathematical Physics (AREA)
- Debugging And Monitoring (AREA)
Abstract
本公开提出一种状态机的控制方法、装置、电子设备及存储介质,涉及计算机技术领域。该方法包括:接收事件处理指令,其中,所述事件处理指令中包括待处理的事件信息;对所述事件信息进行解析,以确定所述待处理的事件的标识及上下文环境信息;根据所述待处理的事件的标识,确定目标状态转移函数;从数据库中获取与所述上下文环境信息关联的状态机的现态;在所述状态机的现态与所述目标状态转移函数对应的开始状态未匹配的情况下,返回事件处理失败消息。由此,无需增加新的状态类等,仅根据事件间的关联关系,即可实现对状态机的控制,从而降低了对状态机控制的复杂性,简化了流程。
The present disclosure provides a control method, device, electronic device and storage medium for a state machine, and relates to the technical field of computers. The method includes: receiving an event processing instruction, wherein the event processing instruction includes event information to be processed; parsing the event information to determine the identifier and context information of the to-be-processed event; The identification of the event to be processed, the target state transition function is determined; the current state of the state machine associated with the context information is obtained from the database; the start state corresponding to the current state of the state machine and the target state transition function In the case of no match, an event processing failure message is returned. Therefore, the state machine can be controlled only according to the correlation between events without adding a new state class, etc., thereby reducing the complexity of the state machine control and simplifying the process.
Description
技术领域technical field
本公开涉及计算机技术领域,尤其涉及一种状态机的控制方法、装置、电子设备及存储介质。The present disclosure relates to the field of computer technologies, and in particular, to a state machine control method, device, electronic device, and storage medium.
背景技术Background technique
随着计算机技术的发展,状态机的热度越来越高,状态机的使用也越来越广泛。相关技术中,在对状态机进行控制过程中,每增加一个状态就需要实现一个新的状态类,并实现其中的行为方法,当事件过多且状态转移比较复杂时,就容易造成混乱。With the development of computer technology, the popularity of state machines has become higher and higher, and the use of state machines has become more and more extensive. In the related art, in the process of controlling a state machine, each time a state is added, a new state class needs to be implemented, and a behavior method in it needs to be implemented. When there are too many events and the state transition is complicated, it is easy to cause confusion.
发明内容SUMMARY OF THE INVENTION
本公开旨在至少在一定程度上解决相关技术中的技术问题之一。The present disclosure aims to solve one of the technical problems in the related art at least to a certain extent.
本公开第一方面实施例提出了一种状态机的控制方法,包括:The embodiment of the first aspect of the present disclosure provides a method for controlling a state machine, including:
接收事件处理指令,其中,所述事件处理指令中包括待处理的事件信息;receiving an event processing instruction, wherein the event processing instruction includes event information to be processed;
对所述事件信息进行解析,以确定所述待处理的事件的标识及上下文环境信息;Parsing the event information to determine the identifier and context information of the event to be processed;
根据所述待处理的事件的标识,确定目标状态转移函数;Determine the target state transition function according to the identifier of the event to be processed;
从数据库中获取与所述上下文环境信息关联的状态机的现态;Obtain the current state of the state machine associated with the context information from the database;
在所述状态机的现态与所述目标状态转移函数对应的开始状态未匹配的情况下,返回事件处理失败消息。If the current state of the state machine does not match the starting state corresponding to the target state transition function, an event processing failure message is returned.
本公开第二方面实施例提出了一种状态机的控制装置,包括:The embodiment of the second aspect of the present disclosure provides a control apparatus for a state machine, including:
接收模块,用于接收事件处理指令,其中,所述事件处理指令中包括待处理的事件信息;a receiving module, configured to receive an event processing instruction, wherein the event processing instruction includes event information to be processed;
解析模块,用于对所述事件信息进行解析,以确定所述待处理的事件的标识及上下文环境信息;a parsing module, configured to parse the event information to determine the identifier and context information of the event to be processed;
确定模块,用于根据所述待处理的事件的标识,确定目标状态转移函数;A determination module for determining a target state transition function according to the identifier of the event to be processed;
获取模块,用于从数据库中获取与所述上下文环境信息关联的状态机的现态;an acquisition module for acquiring the current state of the state machine associated with the context information from the database;
返回模块,用于在所述状态机的现态与所述目标状态转移函数对应的开始状态未匹配的情况下,返回事件处理失败消息。The returning module is configured to return an event processing failure message when the current state of the state machine does not match the starting state corresponding to the target state transition function.
本公开第三方面实施例提出了一种电子设备,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时,实现如本公开第一方面实施例提出的状态机的控制方法。The embodiment of the third aspect of the present disclosure provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and running on the processor, when the processor executes the program, the implementation of the present disclosure The control method of the state machine proposed by the embodiment of the first aspect.
本公开第四方面实施例提出了一种非临时性计算机可读存储介质,存储有计算机程序,所述计算机程序被处理器执行时实现如本公开第一方面实施例提出的状态机的控制方法。Embodiments of the fourth aspect of the present disclosure provide a non-transitory computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, implement the state machine control method provided by the embodiments of the first aspect of the present disclosure .
本公开第五方面实施例提出了一种计算机程序产品,当所述计算机程序产品中的指令处理器执行时,执行本公开第一方面实施例提出的状态机的控制方法。Embodiments of the fifth aspect of the present disclosure provide a computer program product. When an instruction processor in the computer program product is executed, the state machine control method provided by the embodiments of the first aspect of the present disclosure is executed.
本公开提供的状态机的控制方法、装置、电子设备及存储介质,可以先接收事件处理指令,其中,事件处理指令中包括待处理的事件信息,之后对待处理的事件信息进行解析,以确定待处理的事件的标识及上下文环境信息,根据待处理的事件的标识,确定目标状态转移函数,之后可以从数据库中获取与上下文环境信息关联的状态机的现态,在状态机的现态与目标状态转移函数对应的开始状态未匹配的情况下,返回事件处理失败消息。由此,通过对接收的事件信息进行解析,可以确定待处理事件的标识、目标状态转移函数以及上下文环境信息,从而在对状态机控制时,无需增加新的状态类等,仅根据事件间的关联关系,即可实现对状态机的控制,从而降低了对状态机控制的复杂性,简化了流程。The control method, device, electronic device, and storage medium for a state machine provided by the present disclosure may first receive an event processing instruction, wherein the event processing instruction includes event information to be processed, and then analyze the event information to be processed to determine the pending event information. The identification of the event to be processed and the context information, according to the identification of the event to be processed, determine the target state transition function, and then the current state of the state machine associated with the context information can be obtained from the database. If the corresponding start state of the state transition function does not match, an event processing failure message is returned. Therefore, by analyzing the received event information, the identifier of the to-be-processed event, the target state transition function and the context information can be determined, so that when controlling the state machine, there is no need to add a new state class, etc. The association relationship can realize the control of the state machine, thereby reducing the complexity of the state machine control and simplifying the process.
本公开附加的方面和优点将在下面的描述中部分给出,部分将从下面的描述中变得明显,或通过本公开的实践了解到。Additional aspects and advantages of the present disclosure will be set forth, in part, from the following description, and in part will be apparent from the following description, or may be learned by practice of the present disclosure.
附图说明Description of drawings
本公开上述的和/或附加的方面和优点从下面结合附图对实施例的描述中将变得明显和容易理解,其中:The above and/or additional aspects and advantages of the present disclosure will become apparent and readily understood from the following description of embodiments taken in conjunction with the accompanying drawings, wherein:
图1为本公开一实施例所提供的一种状态机的使用流程图;FIG. 1 is a flow chart of using a state machine provided by an embodiment of the present disclosure;
图2为本公开一实施例所提供的状态机的控制方法的流程示意图;FIG. 2 is a schematic flowchart of a control method of a state machine provided by an embodiment of the present disclosure;
图3为本公开一实施例所提供的状态机的控制方法的流程示意图;3 is a schematic flowchart of a method for controlling a state machine provided by an embodiment of the present disclosure;
图4为本公开一实施例所提供的状态机的控制方法的流程示意图;4 is a schematic flowchart of a method for controlling a state machine provided by an embodiment of the present disclosure;
图5为本公开另一实施例所提供的状态机的控制装置的结构示意图;5 is a schematic structural diagram of a control device for a state machine provided by another embodiment of the present disclosure;
图6示出了适于用来实现本公开实施方式的示例性电子设备的框图。6 shows a block diagram of an exemplary electronic device suitable for use in implementing embodiments of the present disclosure.
具体实施方式Detailed ways
下面详细描述本公开的实施例,所述实施例的示例在附图中示出,其中自始至终相同或类似的标号表示相同或类似的元件或具有相同或类似功能的元件。下面通过参考附图描述的实施例是示例性的,旨在用于解释本公开,而不能理解为对本公开的限制。Embodiments of the present disclosure are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals refer to the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary, and are intended to explain the present disclosure and should not be construed as a limitation of the present disclosure.
下面参考附图描述本公开实施例的状态机的控制方法、装置、电子设备和存储介质。The following describes the state machine control method, apparatus, electronic device, and storage medium of the embodiments of the present disclosure with reference to the accompanying drawings.
本公开实施例以该状态机的控制方法被配置于状态机的控制装置中来举例说明,该状态机的控制装置可以应用于任一电子设备中,以使该电子设备可以执行状态机的控制功能。The embodiment of the present disclosure is exemplified by the state machine control method being configured in the state machine control apparatus, the state machine control apparatus can be applied to any electronic device, so that the electronic device can execute the state machine control Function.
可选的,本公开中的执行主体也可以为配置有状态机的控制方法的状态机,本公开对此不做限定。Optionally, the executive body in the present disclosure may also be a state machine configured with a control method of the state machine, which is not limited in the present disclosure.
其中,电子设备可以为个人电脑(Personal Computer,PC)、云端设备、移动设备等,移动设备例如可以为手机、平板电脑、个人数字助理、穿戴式设备、车载设备等具有各种操作系统、触摸屏和/或显示屏的硬件设备。The electronic device may be a personal computer (Personal Computer, PC), a cloud device, a mobile device, etc. The mobile device may be, for example, a mobile phone, a tablet computer, a personal digital assistant, a wearable device, a vehicle-mounted device, etc. with various operating systems, touch screen and/or display hardware.
首先对本公开中提供的状态机进行简单说明。First, a brief description of the state machine provided in the present disclosure is given.
本公开中可以将面向对象的有限状态机M定义为一个七元组,额外引入C作为状态机上下文环境信息,引入A作为状态机行为,其可以表示如下:M=(S,C,E,δ,δ0,F,A)。In this disclosure, the object-oriented finite state machine M can be defined as a seven-tuple, C is additionally introduced as the state machine context information, and A is introduced as the state machine behavior, which can be expressed as follows: M=(S, C, E, δ,δ 0 ,F,A).
其中,状态(state),可以简记为S={s0,s1,…,si},可以表示有限状态的集,通常在一个确定的时刻有一个确定的状态,这个状态是可以组合或者嵌套的。当前状态机的上下文环境信息(context),可以简记为C。Among them, the state (state), which can be abbreviated as S={s 0 , s 1 ,..., s i }, can represent a set of finite states, usually there is a definite state at a definite moment, and this state can be combined or nested. The context information (context) of the current state machine can be abbreviated as C.
事件(event),可以简记为E={e0,e1,…,ei},可以表示有限事件的集合,状态转换可以由事件触发。An event, which can be abbreviated as E={e 0 , e 1 ,..., e i }, can represent a set of limited events, and state transitions can be triggered by events.
δ可以表示状态转移函数:也即其可以理解为事件e在上下文环境信息c下触发了状态s向s’的转移,同时状态机执行了行为a,上下文环境信息为c’。δ can represent the state transition function: that is It can be understood that the event e triggers the transition from the state s to s' under the context information c, and the state machine executes the behavior a, and the context information is c'.
S0∈S可以表示状态机的初始状态,它是S的一个子集;F∈S可以表示状态机的终止状态,它是S的一个子集。S 0 ∈ S can represent the initial state of the state machine, which is a subset of S; F ∈ S can represent the final state of the state machine, which is a subset of S.
状态机的行为(action),可以简记为A,该行为可以根据上下文对象的操作、属性和链接以及触发事件的参数或在其范围内可见的任何其他特征来确定,用来对事件做出反应,维护状态机的健壮性或者实现更多复杂的逻辑。比如,其可以为事件状态转换和事件日志记录,或者对当前环境做出改变等等,本公开对此不做限定。The action of a state machine, which can be abbreviated as A, can be determined from the actions, properties, and links of the context object, as well as the parameters that trigger the event, or any other feature visible within its scope, to make an action on the event. React, maintain the robustness of the state machine or implement more complex logic. For example, it may be event state transition and event logging, or making changes to the current environment, etc., which is not limited in the present disclosure.
下面以图1为例对本公开提供的状态机的使用流程进行简单说明。The following briefly describes the usage flow of the state machine provided by the present disclosure by taking FIG. 1 as an example.
如图1所示。首先可以先定义状态、定义事件、定义状态机行为,再确认是否需要上下文环境信息,若需要上下文环境信息,则可以自定义context,若不需要上下文环境信息,则可以使用默认context,之后可以创建状态机转移实例,接下来可以设计状态转移函数,并构建状态转移规则,之后即可使用状态机。As shown in Figure 1. First, you can define the state, define the event, define the behavior of the state machine, and then confirm whether the context information is required. If the context information is required, you can customize the context. If you do not need the context information, you can use the default context, and then you can create State machine transition instance, then you can design a state transition function, and build a state transition rule, and then you can use the state machine.
需要说明的是,上述示例只是示意性说明,不能作为对本公开实施例中状态机的使用流程等的限定。It should be noted that the above examples are only schematic descriptions, and cannot be used as limitations on the usage flow of the state machine in the embodiments of the present disclosure.
图2为本公开实施例所提供的状态机的控制方法的流程示意图。FIG. 2 is a schematic flowchart of a control method for a state machine provided by an embodiment of the present disclosure.
如图2所示,该状态机的控制方法可以包括以下步骤:As shown in Figure 2, the control method of the state machine may include the following steps:
步骤201,接收事件处理指令,其中,事件处理指令中包括待处理的事件信息。Step 201: Receive an event processing instruction, wherein the event processing instruction includes event information to be processed.
其中,事件处理指令,可以为用户所在的客户端发出的指令信息,其可以为语音形式的指令,或者也可以为其他形式的指令;比如在监测到对应控件被触发时,确定接收事件处理指令。本公开对此不做限定。Among them, the event processing instruction can be the instruction information issued by the client where the user is located, which can be an instruction in the form of voice, or can also be an instruction in other forms; for example, when it is detected that the corresponding control is triggered, it is determined to receive the event processing instruction. . This disclosure does not limit this.
另外,在接收到事件处理指令后,通过对事件处理指令进行分析处理,可以确定其中包含的待处理的事件信息,本公开对此不做限定。In addition, after receiving the event processing instruction, by analyzing and processing the event processing instruction, the to-be-processed event information contained therein can be determined, which is not limited in the present disclosure.
可以理解的是,本公开实施例中,可以采用任何可取的方式对接收的事件处理指令进行分析处理,本公开对此不做限定。It can be understood that, in the embodiment of the present disclosure, the received event processing instruction may be analyzed and processed in any desirable manner, which is not limited in the present disclosure.
步骤202,对待处理的事件信息进行解析,以确定待处理的事件的标识及上下文环境信息。Step 202: Parse the event information to be processed to determine the identifier and context information of the event to be processed.
其中,待处理的事件的标识的样式或者呈现形式,可以为提前设定的,本公开对此不做限定。The style or presentation form of the identifier of the event to be processed may be set in advance, which is not limited in the present disclosure.
另外,上下文环境信息,可以包含待处理事件的业务场景、业务标识等等。本公开对此不做限定。In addition, the context information may include a business scenario, a business identifier, and the like of the event to be processed. This disclosure does not limit this.
可以理解的是,业务标识的样式或者呈现形式,可以为提前设定的。比如对于“仲裁业务”,其对应的业务标识可以为“仲裁”,或者也可以为“ZC”等,其可以唯一表征该业务,本公开对此不做限定。It can be understood that the style or presentation form of the service identification may be set in advance. For example, for "arbitration service", the corresponding service identifier may be "arbitration", or may also be "ZC", etc., which may uniquely characterize the service, which is not limited in the present disclosure.
举例来说,通过对待处理的事件信息进行解析,若确定其中包含“审核员要求用户补充资料、仲裁”,则可以确定待处理事件的标识即为:审核员要求用户补充资料;上下文环境信息中包含的业务场景为:业务仲裁。For example, by analyzing the event information to be processed, if it is determined that it contains "auditor requires user to supplement information and arbitration", it can be determined that the identifier of the pending event is: auditor requires user to supplement information; The included business scenarios are: business arbitration.
需要说明的是,上述示例只是示意性说明,不能作为对本公开实施例中待处理的事件的标识、上下文环境信息等的限定。It should be noted that the above examples are only schematic descriptions, and cannot be used as limitations on the identifiers, contextual environment information, and the like of the events to be processed in the embodiments of the present disclosure.
步骤203,根据待处理的事件的标识,确定目标状态转移函数。Step 203: Determine the target state transition function according to the identifier of the event to be processed.
可以理解的是,不同的事件,其对应的目标状态转移函数,可能相同,或者也可能不同,本公开对此不做限定。It can be understood that, the target state transition functions corresponding to different events may be the same or may be different, which is not limited in the present disclosure.
可选的,可以提前设定不同事件与状态转移函数的对应关系,之后可以根据待处理的事件的标识,从事件与状态转移函数的对应关系中选取该事件标识对应的目标状态转移函数。Optionally, the correspondence between different events and state transition functions may be set in advance, and then the target state transition function corresponding to the event identifier may be selected from the correspondence between events and state transition functions according to the identifier of the event to be processed.
举例来说,已设定:事件1对应的状态转移函数为δ1,事件2对应的状态转移函数为δ2,事件3对应的状态转移函数为δ3。若通过对待处理的事件信息解析确定出待处理的事件的标识为“3”,则可以确定其为事件3,之后通过查找事件与状态转移函数间的对应关系,可以确定对应的目标状态转移函数为δ3。For example, it has been set that the state transition function corresponding to event 1 is δ 1 , the state transition function corresponding to event 2 is δ 2 , and the state transition function corresponding to event 3 is δ 3 . If the identification of the event to be processed is determined to be "3" through the analysis of the event information to be processed, it can be determined as event 3, and then the corresponding target state transition function can be determined by looking up the correspondence between the event and the state transition function. is δ 3 .
需要说明的是,上述示例只是示意性说明,不能作为对本公开实施例中待处理的事件的标识、目标状态转移函数等的限定。It should be noted that the above examples are only schematic descriptions, and cannot be used as limitations on the identification of the event to be processed, the target state transition function, and the like in the embodiments of the present disclosure.
步骤204,从数据库中获取与上下文环境信息关联的状态机的现态。Step 204: Acquire the current state of the state machine associated with the context information from the database.
其中,状态机可以与待处理事件成对应关系。本公开对此不做限定。The state machine may be in a corresponding relationship with the event to be processed. This disclosure does not limit this.
可以理解的是,数据库中可以存储有多条状态机的记录,从而为了提高对事件处理的准确性,可以从数据库中获取与上下文环境信息关联的状态机的现态。It can be understood that a plurality of state machine records can be stored in the database, so that in order to improve the accuracy of event processing, the current state of the state machine associated with the context information can be obtained from the database.
举例来说,若已确定的上下文环境信息为:由用户A发起的仲裁业务。之后,可以在数据库进行查找,以确定与“由用户A发起的仲裁业务”关联的状态机的现态。若在数据库中查找,确定出与“由用户A发起的仲裁业务”关联的信息为:用户A发起申诉仲裁(2月10日);审核员受理(2月11日)。则可以确定与“由用户A发起的仲裁业务”关联的状态机的现态为:审核员受理。For example, if the determined context information is: an arbitration service initiated by user A. Afterwards, the database can be searched to determine the current state of the state machine associated with the "arbitration service initiated by user A". If searched in the database, it is determined that the information associated with the "arbitration service initiated by user A" is: user A initiates appeal arbitration (February 10); the auditor accepts (February 11). Then it can be determined that the current state of the state machine associated with the "arbitration service initiated by user A" is: the auditor accepts.
需要说明的是,上述示例只是示意性说明,不能作为对本公开实施例中上下文环境信息及其关联的状态机的现态等的限定。It should be noted that the above examples are only schematic descriptions, and cannot be used as limitations on the current state of the context information and its associated state machines in the embodiments of the present disclosure.
步骤205,在状态机的现态与目标状态转移函数对应的开始状态未匹配的情况下,返回事件处理失败消息。
可以理解的是,若状态机的现态与目标状态转移函数对应的开始状态不一致,则可以认为状态机的现态与目标状态转移函数对应的开始状态未匹配,此时可以返回事件处理失败消息,也即不对状态机进行控制。It can be understood that if the current state of the state machine is inconsistent with the start state corresponding to the target state transition function, it can be considered that the current state of the state machine does not match the start state corresponding to the target state transition function, and an event processing failure message can be returned at this time. , that is, the state machine is not controlled.
另外,事件处理失败消息,可以为任意可表征事件处理失败的信息。比如可以提前设定:用“0”表征事件处理失败。若确定状态机的现态与目标状态转移函数对应的开始状态未匹配,则可以返回“0”。或者,也可以返回“事件处理失败”提示等等,本公开对此不做限定。In addition, the event processing failure message can be any information that can represent the event processing failure. For example, it can be set in advance: use "0" to represent the event processing failure. If it is determined that the current state of the state machine does not match the starting state corresponding to the target state transition function, "0" may be returned. Alternatively, an "event processing failure" prompt, etc. may also be returned, which is not limited in the present disclosure.
举例来说,若状态机的现态为“用户完成补充资料”,目标状态转移函数对应的开始状态为“审核员要求用户补充资料”,二者不一致,即可认为状态机的现态与目标状态转移函数对应的开始状态未匹配,从而可以返回事件处理失败消息。For example, if the current state of the state machine is "user completes supplementary information", and the corresponding start state of the target state transition function is "auditor requests user supplementary information", if the two are inconsistent, it can be considered that the current state of the state machine is the same as the target. The corresponding start state of the state transition function does not match, so an event processing failure message can be returned.
需要说明的是,上述示例只是示意性说明,不能作为对本公开实施例中状态机的现态、目标状态转移函数对应的开始状态等的限定。It should be noted that the above examples are only schematic descriptions, and cannot be used as limitations on the current state of the state machine, the starting state corresponding to the target state transition function, and the like in the embodiments of the present disclosure.
本公开实施例,可以先接收事件处理指令,其中,事件处理指令中包括待处理的事件信息,之后对待处理的事件信息进行解析,以确定待处理的事件的标识及上下文环境信息,根据待处理的事件的标识,确定目标状态转移函数,之后可以从数据库中获取与上下文环境信息关联的状态机的现态,在状态机的现态与目标状态转移函数对应的开始状态未匹配的情况下,返回事件处理失败消息。由此,通过对接收的事件信息进行解析,可以确定待处理事件的标识、目标状态转移函数以及上下文环境信息,从而在对状态机控制时,无需增加新的状态类等,仅根据事件间的关联关系,即可实现对状态机的控制,从而降低了对状态机控制的复杂性,简化了流程。In this embodiment of the present disclosure, an event processing instruction may be received first, wherein the event processing instruction includes event information to be processed, and then the event information to be processed is parsed to determine the identifier and context information of the event to be processed. The identification of the event, determine the target state transition function, and then the current state of the state machine associated with the context information can be obtained from the database. Returns event processing failure message. Therefore, by analyzing the received event information, the identifier of the to-be-processed event, the target state transition function and the context information can be determined, so that when controlling the state machine, there is no need to add a new state class, etc. The association relationship can realize the control of the state machine, thereby reducing the complexity of the state machine control and simplifying the process.
图3为本公开实施例所提供的状态机的控制方法的流程示意图。如图3所示,该状态机的控制法,可以包括以下步骤:FIG. 3 is a schematic flowchart of a method for controlling a state machine provided by an embodiment of the present disclosure. As shown in Figure 3, the control method of the state machine may include the following steps:
步骤301,接收事件处理指令,其中,事件处理指令中包括待处理的事件信息。Step 301: Receive an event processing instruction, wherein the event processing instruction includes event information to be processed.
步骤302,对事件信息进行解析,以确定待处理的事件的标识及上下文环境信息。Step 302: Parse the event information to determine the identifier and context information of the event to be processed.
步骤303,根据待处理事件的标识,获取待处理事件的属性信息。Step 303: Acquire attribute information of the to-be-processed event according to the identifier of the to-be-processed event.
其中,待处理事件的属性信息,可以包含待处理事件对应的状态转移函数、初始状态、结束状态等,本公开对此不做限定。The attribute information of the to-be-processed event may include a state transition function, an initial state, an end state, etc. corresponding to the to-be-processed event, which is not limited in the present disclosure.
可以理解的是,可以提前设定各个待处理事件对应的属性信息,从而在确定出待处理事件的标识后,可以根据该标识,确定对应的属性信息。It can be understood that the attribute information corresponding to each to-be-processed event may be set in advance, so that after the identifier of the to-be-processed event is determined, the corresponding attribute information may be determined according to the identifier.
步骤304,将待处理事件的属性信息中的状态转移函数,确定为目标状态转移函数。Step 304: Determine the state transition function in the attribute information of the event to be processed as the target state transition function.
举例来说,事件1对应的属性信息为:事件2对应的属性信息为:若待处理事件的标识为“事件1”,根据该标识“事件1”,可以确定其对应的属性信息为:初始状态为:s1,结束状态为:s1’,从而可以将属性信息中的状态转移函数δ1,确定为目标状态转移函数。For example, the attribute information corresponding to event 1 is: The attribute information corresponding to event 2 is: If the identifier of the event to be processed is "event 1", according to the identifier "event 1", it can be determined that its corresponding attribute information is: The initial state is: s 1 , and the end state is: s 1 ', so that the state transition function δ 1 in the attribute information can be determined as the target state transition function.
需要说明的是,上述示例只是示意性说明,不能作为对本公开实施例中待处理事件的标识、对应的属性信息以及状态转移函数等的限定。It should be noted that the above examples are only schematic descriptions, and cannot be used as limitations on the identification of the to-be-processed event, the corresponding attribute information, and the state transition function in the embodiments of the present disclosure.
步骤305,从数据库中获取与上下文环境信息关联的状态转移记录。Step 305: Acquire the state transition record associated with the context information from the database.
其中,状态转移记录,可以指的是当前业务也即待处理事件的历史状态变化信息。本公开对此不做限定。The state transition record may refer to the current business, that is, the historical state change information of the event to be processed. This disclosure does not limit this.
可以理解的是,任一业务或事件,每进行一次处理,都会将处理过程进行记录,也即将该处理过程对应的初始状态、目标状态保存在数据库中。若后续继续对该事件进行处理,则可以对数据库中该事件对应的状态转移记录进行更新并保存。It is understandable that, every time any business or event is processed, the processing process will be recorded, that is, the initial state and target state corresponding to the processing process will be stored in the database. If the event continues to be processed subsequently, the state transition record corresponding to the event in the database can be updated and saved.
步骤306,将状态转移记录中的目标状态,确定为状态机的现态。Step 306: Determine the target state in the state transition record as the current state of the state machine.
其中,状态转移记录中的目标状态,可以理解为状态转移记录中的最新状态或最近时刻的状态。比如,状态转移记录为:用户发起申诉仲裁--审核员受理—审核员要求用户补充资料-用户完成资料补充,则可以确定状态转移记录中的目标状态为:用户完成资料补充。本公开对此不做限定。The target state in the state transition record can be understood as the latest state or the state at the latest moment in the state transition record. For example, if the state transition record is: the user initiates an appeal arbitration - the auditor accepts it - the auditor requests the user to supplement the data - the user completes the data supplement, it can be determined that the target state in the state transition record is: the user completes the data supplement. This disclosure does not limit this.
举例来说,上下文环境信息为:用户B发起的申诉仲裁。之后可以在数据库中查找与“用户B发起的申诉仲裁”关联的状态转移记录。若查找到的状态转移记录为:用户B发起申诉仲裁--审核员C受理—审核员C要求用户B补充资料,则可以确定目标状态为“审核员C要求用户B补充资料”,之后可以确定状态机的现态为:审核员C要求用户B补充资料。For example, the context information is: appeal arbitration initiated by user B. The state transition record associated with "appeal arbitration initiated by user B" can then be searched in the database. If the found state transition record is: User B initiates appeal arbitration - Auditor C accepts - Auditor C requests User B to supplement information, the target state can be determined to be "Auditor C requires User B to supplement information", and then it can be determined The current state of the state machine is: Auditor C requires User B to supplement information.
需要说明的是,上述示例只是示意性说明,不能作为对本公开实施例中上下文环境信息、及其关联的状态转移记录以及该状态转移记录中的目标状态等的限定。It should be noted that the above examples are only schematic descriptions, and cannot be used as limitations on the contextual environment information, its associated state transition records, and target states in the state transition records in the embodiments of the present disclosure.
步骤307,在状态机的现态与目标状态转移函数对应的开始状态未匹配的情况下,返回事件处理失败消息。
步骤308,在状态机的现态与目标状态转移函数对应的开始状态匹配情况下,确定待处理事件对应的转移条件。
可以理解的是,若状态机的现态与目标状态转移函数对应的开始状态一致,则可以认为状态机的现态与目标状态转移函数对应的开始状态匹配。It can be understood that if the current state of the state machine is consistent with the start state corresponding to the target state transition function, it can be considered that the current state of the state machine matches the start state corresponding to the target state transition function.
比如,状态机的现态为“用户完成补充资料”,目标状态转移函数对应的开始状态为“用户完成资料补充”,二者一致,即可认为状态机的现态与目标状态转移函数对应的开始状态匹配,之后可以确定待处理事件对应的转移条件。本公开对此不做限定。For example, if the current state of the state machine is "user completes supplementary data", and the start state corresponding to the target state transition function is "user completes data supplementation", if the two are consistent, it can be considered that the current state of the state machine corresponds to the target state transition function. The starting state is matched, and then the transition condition corresponding to the pending event can be determined. This disclosure does not limit this.
另外,待处理事件对应的转移条件,可以为在事件定义时自行设置的,或者也可以为根据规则设定的,或者也可以为默认条件等等,本公开对此不做限定。In addition, the transition condition corresponding to the to-be-processed event may be set by yourself when the event is defined, or may be set according to a rule, or may be a default condition, etc., which is not limited in the present disclosure.
举例来说,可以提前设定事件1由目标状态转移函数对应的开始状态A转移至结束状态B所需的转移条件a1;事件2由目标状态转移函数对应的开始状态C转移至结束状态D所需的转移条件a2;事件3由目标状态转移函数对应的开始状态E转移至结束状态F所需的转移条件a3。若已确定出待处理事件1的现态与目标转移函数对应的开始状态A匹配,则可以确定待处理事件1对应的转移条件为:a1。For example, the transition condition a 1 required for event 1 to transition from the start state A corresponding to the target state transition function to the end state B can be set in advance; the event 2 transitions from the start state C corresponding to the target state transition function to the end state D. The required transition condition a 2 ; the transition condition a 3 required for event 3 to transition from the start state E corresponding to the target state transition function to the end state F. If it is determined that the current state of the event 1 to be processed matches the starting state A corresponding to the target transition function, it can be determined that the transition condition corresponding to the event 1 to be processed is: a 1 .
需要说明的是,上述示例只是示意性说明,不能作为对本公开实施例中,待处理事件对应的转移条件等的限定。It should be noted that the above examples are only schematic descriptions, and cannot be used as limitations on the transition conditions and the like corresponding to the events to be processed in the embodiments of the present disclosure.
步骤309,在状态机当前的条件满足转移条件的情况下,将状态机由现态向目标转移函数对应的结束状态转移。
举例来说,若待处理事件1的现态与目标转移函数对应的开始状态“审核员要求用户A补充资料”匹配,确定的转移条件为:资料已补充。若当前用户A已补充相关资料,则可以确定状态机当前的条件满足对应的转移条件,之后可以将状态机由现态“审核员要求用户A补充资料”向目标转移函数对应的结束状态“用户完成补充资料”转移。For example, if the current state of event 1 to be processed matches the start state "auditor requires user A to supplement data" corresponding to the target transition function, the determined transition condition is: data has been supplemented. If the current user A has supplemented relevant data, it can be determined that the current conditions of the state machine satisfy the corresponding transition conditions, and then the state machine can be transferred from the current state "auditor requires user A to supplement data" to the end state "user A" corresponding to the target transition function. Complete Supplementary Information" transfer.
需要说明的是,上述示例只是示意性说明,不能作为对本公开实施中状态机当前的条件、转移条件以及目标转移函数对应的结束状态等的限定。It should be noted that the above examples are only schematic descriptions, and cannot be used as limitations on the current conditions, transition conditions, and end states corresponding to the target transition function of the state machine in the implementation of the present disclosure.
本公开实施例,可以先接收事件处理指令,其中,事件处理指令中包括待处理的事件信息,之后对事件信息进行解析,以确定待处理的事件的标识及上下文环境信息,再根据待处理事件的标识,获取待处理事件的属性信息,之后可以将待处理事件的属性信息中的状态转移函数,确定为目标状态转移函数,并从数据库中获取与上下文环境信息关联的状态转移记录,之后可以将状态转移记录中的目标状态,确定为状态机的现态,在状态机的现态与目标状态转移函数对应的开始状态未匹配的情况下,返回事件处理失败消息,在状态机的现态与目标状态转移函数对应的开始状态匹配情况下,确定待处理事件对应的转移条件,在状态机当前的条件满足转移条件的情况下,将状态机由现态向目标转移函数对应的结束状态转移。由此,在对接收的事件信息进行解析后,可以根据待处理事件的标识,确定目标状态转移函数,并根据上下文环境信息获取关联的状态机的现态,之后根据状态机的现态与目标状态转移函数对应的开始状态的匹配情况,即可实现对状态机的控制,该过程无需增加新的状态类等,避免了类膨胀等问题,从而降低了对状态机控制的复杂性,简化了流程。In this embodiment of the present disclosure, an event processing instruction may be received first, wherein the event processing instruction includes event information to be processed, and then the event information is parsed to determine the identifier and context information of the to-be-processed event, and then according to the to-be-processed event , obtain the attribute information of the event to be processed, and then determine the state transition function in the attribute information of the event to be processed as the target state transition function, and obtain the state transition record associated with the context information from the database. The target state in the state transition record is determined as the current state of the state machine. If the current state of the state machine does not match the start state corresponding to the target state transition function, an event processing failure message is returned, and the current state of the state machine is returned. When the start state corresponding to the target state transition function matches, determine the transition condition corresponding to the event to be processed, and when the current condition of the state machine satisfies the transition condition, transfer the state machine from the current state to the end state corresponding to the target transition function . Therefore, after analyzing the received event information, the target state transition function can be determined according to the identifier of the event to be processed, and the current state of the associated state machine can be obtained according to the context information, and then the current state of the state machine and the target state can be obtained according to the current state of the state machine. The matching of the starting state corresponding to the state transition function can realize the control of the state machine. This process does not need to add new state classes, etc., which avoids problems such as class expansion, thereby reducing the complexity of the state machine control and simplifying the process. process.
图4为本公开实施例所提供的状态机的控制方法的流程示意图。如图4所示,该状态机的控制法,可以包括以下步骤:FIG. 4 is a schematic flowchart of a method for controlling a state machine provided by an embodiment of the present disclosure. As shown in Figure 4, the control method of the state machine may include the following steps:
步骤401,接收事件处理指令,其中,事件处理指令中包括待处理的事件信息。Step 401: Receive an event processing instruction, wherein the event processing instruction includes event information to be processed.
步骤402,对事件信息进行解析,以确定待处理的事件的标识及上下文环境信息。Step 402: Parse the event information to determine the identifier and context information of the event to be processed.
步骤403,根据待处理的事件的标识,确定目标状态转移函数。Step 403: Determine the target state transition function according to the identifier of the event to be processed.
步骤404,从数据库中获取与上下文环境信息关联的状态机的现态。Step 404: Acquire the current state of the state machine associated with the context information from the database.
步骤405,在状态机的现态与目标状态转移函数对应的开始状态匹配情况下,确定待处理事件对应的转移条件。
步骤406,在状态机当前的条件满足转移条件的情况下,将状态机由现态向目标转移函数对应的结束状态转移。
需要说明的是,步骤401至步骤406的具体内容及实现方式,可以参照本公开其他各实施例的说明,此处不再赘述。It should be noted that, for the specific content and implementation manner of
步骤407,根据现态及结束状态,生成并暂存当前的状态转移记录。
举例来说,若现态为“用户完成结果确认”,结束状态为“管理员操作办结”,则生成的当前的状态转移记录可以为:用户完成结果确认--管理员操作办结;之后可以将该条状态转移记录进行暂存。For example, if the current state is "User completed result confirmation" and the end state is "Administrator operation completed", the current state transition record generated can be: User completed result confirmation-Administrator operation completed; then This state transition record can be temporarily stored.
或者,若从数据库中获取的状态转移记录为“用户发起申诉仲裁—审核员受理--审核员要求用户补充资料”;状态机的现态为“审核员要求用户补充资料”,结束状态为“用户完成补充资料”,则生成的当前的状态转移记录可以为:“用户发起申诉仲裁—审核员受理--审核员要求用户补充资料—用户完成资料补充”,之后可以将该条状态转移记录进行暂存。Or, if the state transition record obtained from the database is “User initiates appeal arbitration—auditor accepts—auditor requests user supplementary information”; the current state of the state machine is “auditor requests user supplementary information”, and the end state is “ User completes supplementary information”, the current state transfer record generated can be: “User initiates appeal arbitration—auditor accepts—auditor requests user supplementary information—user completes data supplementation”, and then this state transfer record can be processed. Staging.
需要说明的是,上述示例只是示意性说明,不能作为对本公开实施例中现态、结束状态以及当前的状态转移记录等的限定。It should be noted that the above examples are only schematic descriptions, and cannot be used as limitations on the current state, the ending state, the current state transition record, and the like in the embodiments of the present disclosure.
步骤408,确定数据库中与待处理的事件信息关联的状态转移记录的版本号的取值。Step 408: Determine the value of the version number of the state transition record associated with the to-be-processed event information in the database.
其中,状态转移记录的版本号,可以唯一表征该状态转移记录的版本信息,版本号的取值可以为任意可取的数值,本公开对此不做限定。The version number of the state transition record can uniquely represent the version information of the state transition record, and the value of the version number can be any value, which is not limited in the present disclosure.
可以理解的是,可以通过读取与待处理的事件信息关联的状态转移记录,从而确定该状态转移记录的版本号的取值。It can be understood that the value of the version number of the state transition record can be determined by reading the state transition record associated with the to-be-processed event information.
举例来说,若与待处理的事件信息关联的状态转移记录的名称中包含“NO.1”,则可以确定该状态转移记录的版本号的取值为1。本公开对此不做限定。For example, if the name of the state transition record associated with the to-be-processed event information contains "NO.1", it can be determined that the value of the version number of the state transition record is 1. This disclosure does not limit this.
步骤409,在版本号的取值小于阈值的情况下,根据暂存的状态转移记录,更新数据库中与待处理的事件信息关联的状态转移记录,并将版本号的取值加一。
其中,阈值,可以为提前设定的数值,本公开对此不做限定。The threshold value may be a value set in advance, which is not limited in the present disclosure.
举例来说,若设定的阈值为1,当前的版本号为0,暂存的状态转移记录为“审核员要求用户补充资料—用户完成补充资料”,数据库中与待处理的事件信息关联的状态转移记录为“用户发起申诉仲裁--审核员受理--审核员要求用户补充资料”,当前的版本号小于设定的阈值,则可以对数据库中与待处理的事件信息关联的状态转移记录进行更新,更新后的状态转移记录可以为“用户发起申诉仲裁--审核员受理--审核员要求用户补充资料—用户完成补充资料”,之后可以将版本号的取值加一,则更新后的版本号可以为1。For example, if the set threshold is 1, the current version number is 0, and the temporarily stored state transition record is "Auditor requests user supplementary information—User completes supplementary information", the database is associated with the pending event information. The state transition record is "User initiates appeal arbitration -- auditor accepts -- auditor requests user supplementary information", if the current version number is less than the set threshold, the state transition record associated with the pending event information in the database can be recorded. After updating, the updated state transfer record can be "User initiates appeal arbitration -- Auditor accepts -- Auditor requests user supplementary information -- User completes supplementary information", and then the value of the version number can be increased by one, then after the update The version number can be 1.
需要说明的是,上述示例只是示意性说明,不能作为对本公开实施例中版本号的取值、阈值、状态转移记录等的限定。It should be noted that the above examples are only schematic descriptions, and cannot be used as limitations on the values, thresholds, state transition records, etc. of the version numbers in the embodiments of the present disclosure.
可选的,在版本号的取值等于阈值的情况下,删除当前的状态转移记录。Optionally, when the value of the version number is equal to the threshold, delete the current state transition record.
举例来说,若设定的阈值为1,当前的版本号为1,当前暂存的状态转移记录为“审核员要求用户补充资料—用户完成补充资料”,则可以删除当前的状态转移记录。本公开对此不做限定。For example, if the set threshold is 1, the current version number is 1, and the currently temporarily stored state transition record is "Auditor requires user to supplement information - user completes supplementary information", the current state transition record can be deleted. This disclosure does not limit this.
可以理解的是,若版本号的取值等于阈值,可以表明该事件已被处理过,为了避免事件重复处理,可以将暂存的状态转移记录删除,从而保证了事件处理与状态机控制的准确性和可靠性。It can be understood that if the value of the version number is equal to the threshold, it can indicate that the event has been processed. In order to avoid repeated processing of the event, the temporarily stored state transition record can be deleted, thus ensuring the accuracy of event processing and state machine control. sturdiness and reliability.
举例来说,在连续较短的时间内多次接收到同一个事件处理指令,若状态机1先执行了该待处理的事件,并将关联的状态转移记录存储至数据库中,并将对应的版本号更新为:1。若状态机2也在执行该待处理的事件,在生成当前的状态转移记录后,可以先确定数据库中该事件的状态转移记录的版本号,若确定版本号为1,设定的阈值也为1,二者相等,则状态机2可以将其对应的暂存的状态转移记录进行删除。For example, if the same event processing instruction is received multiple times in a short period of time, if state machine 1 executes the pending event first, stores the associated state transition record in the database, and stores the corresponding state transition record in the database. The version number is updated to: 1. If the state machine 2 is also executing the pending event, after generating the current state transition record, the version number of the state transition record of the event in the database can be determined first. If the version number is determined to be 1, the set threshold is also 1, the two are equal, then state machine 2 can delete its corresponding temporary state transition record.
需要说明的是,上述示例只是示意性说明,不能作为对本公开实施例中状态转移记录的版本号、阈值等的限定。It should be noted that the above examples are only schematic descriptions, and cannot be used as limitations on the version numbers, thresholds, etc. of the state transition records in the embodiments of the present disclosure.
本公开实施例,在状态机当前的条件满足转移条件的情况下,可以将状态机由现态向目标转移函数对应的结束状态转移,之后可以根据现态及结束状态,生成并暂存当前的状态转移记录,并确定数据库中与待处理的事件信息关联的状态转移记录的版本号的取值,在版本号的取值小于阈值的情况下,根据暂存的状态转移记录,更新数据库中与所述待处理的事件信息关联的状态转移记录,并将版本号的取值加一。由此,可以先根据状态机的现态及结束状态,生成并暂存当前的状态转移记录,之后在数据库中关联的状态转移函数的版本号的取值小于阈值时,可以根据暂存的状态转移记录对数据库中关联的状态转移记录进行更新,该过程无需增加新的状态类等,仅根据事件间的关联关系,即可实现对状态机的控制,从而降低了对状态机控制的复杂性,简化了流程In the embodiment of the present disclosure, when the current condition of the state machine satisfies the transition condition, the state machine can be transferred from the current state to the end state corresponding to the target transition function, and then the current state and the end state can be generated and temporarily stored. State transition record, and determine the value of the version number of the state transition record associated with the event information to be processed in the database. The state transition record associated with the to-be-processed event information, and the value of the version number is incremented by one. In this way, the current state transition record can be generated and temporarily stored according to the current state and end state of the state machine, and then when the value of the version number of the associated state transition function in the database is less than the threshold, the current state transition record can be temporarily stored according to the state The transition record updates the associated state transition record in the database. This process does not need to add new state classes, etc., and can control the state machine only according to the correlation between events, thereby reducing the complexity of state machine control. , which simplifies the process
为了实现上述实施例,本公开还提出一种状态机的控制装置。In order to realize the above embodiments, the present disclosure also proposes a control apparatus for a state machine.
图5为本公开实施例所提供的状态机的控制装置的结构示意图。FIG. 5 is a schematic structural diagram of a control apparatus for a state machine provided by an embodiment of the present disclosure.
如图5所示,该状态机的控制装置100可以包括:接收模块110、解析模块120、确定模块130、获取模块140及返回模块150。As shown in FIG. 5 , the
其中,接收模块110,用于接收事件处理指令,其中,所述事件处理指令中包括待处理的事件信息。The receiving
解析模块120,用于对所述事件信息进行解析,以确定所述待处理的事件的标识及上下文环境信息。The
确定模块130,用于根据所述待处理的事件的标识,确定目标状态转移函数。The determining
获取模块140,用于从数据库中获取与所述上下文环境信息关联的状态机的现态。The obtaining
返回模块150,用于在所述状态机的现态与所述目标状态转移函数对应的开始状态未匹配的情况下,返回事件处理失败消息。The returning
可选的,所述确定模块130,具体用于:Optionally, the determining
根据所述待处理事件的标识,获取所述待处理事件的属性信息;Obtain attribute information of the to-be-processed event according to the identifier of the to-be-processed event;
将所述待处理事件的属性信息中的状态转移函数,确定为所述目标状态转移函数。The state transition function in the attribute information of the to-be-processed event is determined as the target state transition function.
可选的,所述获取模块140,具体用于:Optionally, the obtaining
从所述数据库中获取与所述上下文环境信息关联的状态转移记录;obtaining a state transition record associated with the context information from the database;
将所述状态转移记录中的目标状态,确定为所述状态机的现态。The target state in the state transition record is determined as the current state of the state machine.
可选的,所述确定模块130,还用于:Optionally, the determining
在所述状态机的现态与所述目标状态转移函数对应的开始状态匹配情况下,确定所述待处理事件对应的转移条件;Under the condition that the current state of the state machine matches the starting state corresponding to the target state transition function, determining the transition condition corresponding to the event to be processed;
在所述状态机当前的条件满足所述转移条件的情况下,将所述状态机由现态向所述目标转移函数对应的结束状态转移。When the current condition of the state machine satisfies the transition condition, the state machine is transitioned from the current state to the end state corresponding to the target transition function.
可选的,所述确定模块130,还用于:Optionally, the determining
根据所述现态及所述结束状态,生成并暂存当前的状态转移记录;According to the current state and the end state, generate and temporarily store the current state transition record;
确定所述数据库中与所述待处理的事件信息关联的状态转移记录的版本号的取值;determining the value of the version number of the state transition record associated with the to-be-processed event information in the database;
在所述版本号的取值小于阈值的情况下,根据暂存的所述状态转移记录,更新所述数据库中与所述待处理的事件信息关联的状态转移记录,并将所述版本号的取值加一。When the value of the version number is less than the threshold, update the state transition record associated with the pending event information in the database according to the temporarily stored state transition record, and convert the version number to the state transition record. The value is incremented by one.
可选的,所述确定模块130,还用于:Optionally, the determining
在所述版本号的取值等于阈值的情况下,删除所述当前的状态转移记录。When the value of the version number is equal to the threshold, the current state transition record is deleted.
本公开实施例中的上述各模块的功能及具体实现原理,可参照上述各方法实施例,此处不再赘述。For the functions and specific implementation principles of the foregoing modules in the embodiments of the present disclosure, reference may be made to the foregoing method embodiments, and details are not described herein again.
本公开实施例的状态机的控制装置,可以先接收事件处理指令,其中,事件处理指令中包括待处理的事件信息,之后对待处理的事件信息进行解析,以确定待处理的事件的标识及上下文环境信息,根据待处理的事件的标识,确定目标状态转移函数,之后可以从数据库中获取与上下文环境信息关联的状态机的现态,在状态机的现态与目标状态转移函数对应的开始状态未匹配的情况下,返回事件处理失败消息。由此,通过对接收的事件信息进行解析,可以确定待处理事件的标识、目标状态转移函数以及上下文环境信息,从而在对状态机控制时,无需增加新的状态类等,仅根据事件间的关联关系,即可实现对状态机的控制,从而降低了对状态机控制的复杂性,简化了流程。The control device of the state machine in the embodiment of the present disclosure may first receive an event processing instruction, wherein the event processing instruction includes the event information to be processed, and then parse the event information to be processed to determine the identifier and context of the to-be-processed event Environment information, determine the target state transition function according to the identifier of the event to be processed, and then obtain the current state of the state machine associated with the contextual environment information from the database, and the start state corresponding to the current state of the state machine and the target state transition function In the case of no match, an event processing failure message is returned. Therefore, by analyzing the received event information, the identifier of the to-be-processed event, the target state transition function and the context information can be determined, so that when controlling the state machine, there is no need to add a new state class, etc. The association relationship can realize the control of the state machine, thereby reducing the complexity of the state machine control and simplifying the process.
为了实现上述实施例,本公开还提出一种电子设备,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,处理器执行程序时,实现如本公开前述实施例提出的状态机的控制方法。In order to implement the above-mentioned embodiments, the present disclosure also proposes an electronic device, including: a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the program, the above-mentioned embodiments of the present disclosure are implemented. The proposed state machine control method.
为了实现上述实施例,本公开还提出一种非临时性计算机可读存储介质,存储有计算机程序,计算机程序被处理器执行时实现如本公开前述实施例提出的状态机的控制方法。In order to implement the above embodiments, the present disclosure also provides a non-transitory computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, implements the state machine control method provided by the foregoing embodiments of the present disclosure.
为了实现上述实施例,本公开还提出一种计算机程序产品,当计算机程序产品中的指令处理器执行时,执行如本公开前述实施例提出的状态机的控制方法。In order to realize the above embodiments, the present disclosure also provides a computer program product, when the instruction processor in the computer program product executes, executes the state machine control method proposed by the foregoing embodiments of the present disclosure.
图6示出了适于用来实现本公开实施方式的示例性电子设备的框图。图6显示的电子设备12仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。6 shows a block diagram of an exemplary electronic device suitable for use in implementing embodiments of the present disclosure. The
如图6所示,电子设备12以通用计算设备的形式表现。电子设备12的组件可以包括但不限于:一个或者多个处理器或者处理单元16,系统存储器28,连接不同系统组件(包括系统存储器28和处理单元16)的总线18。As shown in FIG. 6, the
总线18表示几类总线结构中的一种或多种,包括存储器总线或者存储器控制器,外围总线,图形加速端口,处理器或者使用多种总线结构中的任意总线结构的局域总线。举例来说,这些体系结构包括但不限于工业标准体系结构(Industry StandardArchitecture,ISA)总线,微通道体系结构(Micro Channel Architecture,MAC)总线,增强型ISA总线、视频电子标准协会(Video Electronics Standards Association,VESA)局域总线以及外围组件互连(Peripheral Component Interconnection,PCI)总线。
电子设备12典型地包括多种计算机系统可读介质。这些介质可以是任何能够被电子设备12访问的可用介质,包括易失性和非易失性介质,可移动的和不可移动的介质。
存储器28可以包括易失性存储器形式的计算机系统可读介质,例如随机存取存储器(Random Access Memory,RAM)30和/或高速缓存存储器32。电子设备12可以进一步包括其它可移动/不可移动的、易失性/非易失性计算机系统存储介质。仅作为举例,存储系统34可以用于读写不可移动的、非易失性磁介质(图6未显示,通常称为“硬盘驱动器”)。尽管图6中未示出,可以提供用于对可移动非易失性磁盘(例如“软盘”)读写的磁盘驱动器,以及对可移动非易失性光盘(例如:光盘只读存储器(Compact Disc Read Only Memory,CD-ROM)、数字多功能只读光盘(Digital Video Disc Read Only Memory,DVD-ROM)或者其它光介质)读写的光盘驱动器。在这些情况下,每个驱动器可以通过一个或者多个数据介质接口与总线18相连。存储器28可以包括至少一个程序产品,该程序产品具有一组(例如至少一个)程序模块,这些程序模块被配置以执行本公开各实施例的功能。
具有一组(至少一个)程序模块42的程序/实用工具40,可以存储在例如存储器28中,这样的程序模块42包括但不限于操作系统、一个或者多个应用程序、其它程序模块以及程序数据,这些示例中的每一个或某种组合中可能包括网络环境的实现。程序模块42通常执行本公开所描述的实施例中的功能和/或方法。A program/
电子设备12也可以与一个或多个外部设备14(例如键盘、指向设备、显示器24等)通信,还可与一个或者多个使得用户能与该电子设备12交互的设备通信,和/或与使得该电子设备12能与一个或多个其它计算设备进行通信的任何设备(例如网卡,调制解调器等等)通信。这种通信可以通过输入/输出(I/O)接口22进行。并且,电子设备12还可以通过网络适配器20与一个或者多个网络(例如局域网(Local Area Network,LAN),广域网(Wide AreaNetwork,WAN)和/或公共网络,例如因特网)通信。如图所示,网络适配器20通过总线18与电子设备12的其它模块通信。应当明白,尽管图中未示出,可以结合电子设备12使用其它硬件和/或软件模块,包括但不限于:微代码、设备驱动器、冗余处理单元、外部磁盘驱动阵列、RAID系统、磁带驱动器以及数据备份存储系统等。The
处理单元16通过运行存储在系统存储器28中的程序,从而执行各种功能应用以及数据处理,例如实现前述实施例中提及的方法。The
本公开的技术方案,可以先接收事件处理指令,其中,事件处理指令中包括待处理的事件信息,之后对待处理的事件信息进行解析,以确定待处理的事件的标识及上下文环境信息,根据待处理的事件的标识,确定目标状态转移函数,之后可以从数据库中获取与上下文环境信息关联的状态机的现态,在状态机的现态与目标状态转移函数对应的开始状态未匹配的情况下,返回事件处理失败消息。由此,通过对接收的事件信息进行解析,可以确定待处理事件的标识、目标状态转移函数以及上下文环境信息,从而在对状态机控制时,无需增加新的状态类等,仅根据事件间的关联关系,即可实现对状态机的控制,从而降低了对状态机控制的复杂性,简化了流程。In the technical solution of the present disclosure, an event processing instruction may be received first, wherein the event processing instruction includes event information to be processed, and then the event information to be processed is parsed to determine the identifier and context information of the event to be processed. The identification of the processed event, the target state transition function is determined, and then the current state of the state machine associated with the context information can be obtained from the database. In the case where the current state of the state machine does not match the starting state corresponding to the target state transition function , which returns the event processing failure message. Therefore, by analyzing the received event information, the identifier of the to-be-processed event, the target state transition function and the context information can be determined, so that when controlling the state machine, there is no need to add a new state class, etc. The association relationship can realize the control of the state machine, thereby reducing the complexity of the state machine control and simplifying the process.
在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本公开的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不必须针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。In the description of this specification, description with reference to the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples", etc., mean specific features described in connection with the embodiment or example , structures, materials, or features are included in at least one embodiment or example of the present disclosure. In this specification, schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the particular features, structures, materials or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, those skilled in the art may combine and combine the different embodiments or examples described in this specification, as well as the features of the different embodiments or examples, without conflicting each other.
此外,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。在本公开的描述中,“多个”的含义是至少两个,例如两个,三个等,除非另有明确具体的限定。In addition, the terms "first" and "second" are only used for descriptive purposes, and should not be construed as indicating or implying relative importance or implying the number of indicated technical features. Thus, a feature delimited with "first", "second" may expressly or implicitly include at least one of that feature. In the description of the present disclosure, "plurality" means at least two, such as two, three, etc., unless expressly and specifically defined otherwise.
流程图中或在此以其他方式描述的任何过程或方法描述可以被理解为,表示包括一个或更多个用于实现定制逻辑功能或过程的步骤的可执行指令的代码的模块、片段或部分,并且本公开的优选实施方式的范围包括另外的实现,其中可以不按所示出或讨论的顺序,包括根据所涉及的功能按基本同时的方式或按相反的顺序,来执行功能,这应被本公开的实施例所属技术领域的技术人员所理解。Any process or method description in the flowcharts or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing custom logical functions or steps of the process , and the scope of the preferred embodiments of the present disclosure includes alternative implementations in which the functions may be performed out of the order shown or discussed, including performing the functions substantially concurrently or in the reverse order depending upon the functions involved, which should It is understood by those skilled in the art to which the embodiments of the present disclosure pertain.
在流程图中表示或在此以其他方式描述的逻辑和/或步骤,例如,可以被认为是用于实现逻辑功能的可执行指令的定序列表,可以具体实现在任何计算机可读介质中,以供指令执行系统、装置或设备(如基于计算机的系统、包括处理器的系统或其他可以从指令执行系统、装置或设备取指令并执行指令的系统)使用,或结合这些指令执行系统、装置或设备而使用。就本说明书而言,"计算机可读介质"可以是任何可以包含、存储、通信、传播或传输程序以供指令执行系统、装置或设备或结合这些指令执行系统、装置或设备而使用的装置。计算机可读介质的更具体的示例(非穷尽性列表)包括以下:具有一个或多个布线的电连接部(电子装置),便携式计算机盘盒(磁装置),随机存取存储器(RAM),只读存储器(ROM),可擦除可编辑只读存储器(EPROM或闪速存储器),光纤装置,以及便携式光盘只读存储器(CDROM)。另外,计算机可读介质甚至可以是可在其上打印所述程序的纸或其他合适的介质,因为可以例如通过对纸或其他介质进行光学扫描,接着进行编辑、解译或必要时以其他合适方式进行处理来以电子方式获得所述程序,然后将其存储在计算机存储器中。The logic and/or steps represented in flowcharts or otherwise described herein, for example, may be considered an ordered listing of executable instructions for implementing the logical functions, may be embodied in any computer-readable medium, For use with, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other system that can fetch instructions from and execute instructions from an instruction execution system, apparatus, or apparatus) or equipment. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport the program for use by or in connection with an instruction execution system, apparatus, or apparatus. More specific examples (non-exhaustive list) of computer readable media include the following: electrical connections with one or more wiring (electronic devices), portable computer disk cartridges (magnetic devices), random access memory (RAM), Read Only Memory (ROM), Erasable Editable Read Only Memory (EPROM or Flash Memory), Fiber Optic Devices, and Portable Compact Disc Read Only Memory (CDROM). In addition, the computer readable medium may even be paper or other suitable medium on which the program may be printed, as the paper or other medium may be optically scanned, for example, followed by editing, interpretation, or other suitable medium as necessary process to obtain the program electronically and then store it in computer memory.
应当理解,本公开的各部分可以用硬件、软件、固件或它们的组合来实现。在上述实施方式中,多个步骤或方法可以用存储在存储器中且由合适的指令执行系统执行的软件或固件来实现。如,如果用硬件来实现和在另一实施方式中一样,可用本领域公知的下列技术中的任一项或他们的组合来实现:具有用于对数据信号实现逻辑功能的逻辑门电路的离散逻辑电路,具有合适的组合逻辑门电路的专用集成电路,可编程门阵列(PGA),现场可编程门阵列(FPGA)等。It should be understood that portions of the present disclosure may be implemented in hardware, software, firmware, or a combination thereof. In the above-described embodiments, various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented by any one of the following techniques known in the art, or a combination thereof: discrete with logic gates for implementing logic functions on data signals Logic circuits, application specific integrated circuits with suitable combinational logic gates, Programmable Gate Arrays (PGA), Field Programmable Gate Arrays (FPGA), etc.
本技术领域的普通技术人员可以理解实现上述实施例方法携带的全部或部分步骤是可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,该程序在执行时,包括方法实施例的步骤之一或其组合。Those skilled in the art can understand that all or part of the steps carried by the methods of the above embodiments can be completed by instructing the relevant hardware through a program, and the program can be stored in a computer-readable storage medium, and the program can be stored in a computer-readable storage medium. When executed, one or a combination of the steps of the method embodiment is included.
此外,在本公开各个实施例中的各功能单元可以集成在一个处理模块中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。所述集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing module, or each unit may exist physically alone, or two or more units may be integrated into one module. The above-mentioned integrated modules can be implemented in the form of hardware, and can also be implemented in the form of software function modules. If the integrated modules are implemented in the form of software functional modules and sold or used as independent products, they may also be stored in a computer-readable storage medium.
上述提到的存储介质可以是只读存储器,磁盘或光盘等。尽管上面已经示出和描述了本公开的实施例,可以理解的是,上述实施例是示例性的,不能理解为对本公开的限制,本领域的普通技术人员在本公开的范围内可以对上述实施例进行变化、修改、替换和变型。The above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, and the like. Although the embodiments of the present disclosure have been shown and described above, it should be understood that the above-described embodiments are exemplary and should not be construed as limitations of the present disclosure, and those of ordinary skill in the art may interpret the above-described embodiments within the scope of the present disclosure. Embodiments are subject to variations, modifications, substitutions and variations.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210125108.8A CN114461691B (en) | 2022-02-10 | 2022-02-10 | Control method and device of state machine, electronic equipment and storage medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210125108.8A CN114461691B (en) | 2022-02-10 | 2022-02-10 | Control method and device of state machine, electronic equipment and storage medium |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN114461691A true CN114461691A (en) | 2022-05-10 |
| CN114461691B CN114461691B (en) | 2025-08-01 |
Family
ID=81412790
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202210125108.8A Active CN114461691B (en) | 2022-02-10 | 2022-02-10 | Control method and device of state machine, electronic equipment and storage medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN114461691B (en) |
Cited By (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114844711A (en) * | 2022-05-17 | 2022-08-02 | 北京经纬恒润科技股份有限公司 | A kind of vehicle Ethernet security state detection method and device |
| CN115756439A (en) * | 2022-10-20 | 2023-03-07 | 乾三(北京)科技有限公司 | State machine engine arrangement method and device and computer equipment |
| CN116431801A (en) * | 2023-03-29 | 2023-07-14 | 魔方医药科技(苏州)有限公司 | Text matching method and device, electronic equipment and storage medium |
| CN117993905A (en) * | 2024-02-06 | 2024-05-07 | 易方达基金管理有限公司 | Instruction state machine-based repainting method and device |
| WO2024176302A1 (en) * | 2023-02-20 | 2024-08-29 | 三菱電機株式会社 | State transition management device, state transition management method, and state transition management program |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109582398A (en) * | 2018-11-23 | 2019-04-05 | 阿里巴巴集团控股有限公司 | A kind of condition processing method, device and electronic equipment |
| CN109731334A (en) * | 2018-11-22 | 2019-05-10 | 腾讯科技(深圳)有限公司 | Switching method and apparatus, storage medium, the electronic device of state |
| CN112068810A (en) * | 2020-08-27 | 2020-12-11 | 北京五八信息技术有限公司 | Activity event processing method and device, electronic equipment and storage medium |
| CN112561057A (en) * | 2020-12-09 | 2021-03-26 | 清华大学 | State control method and device |
-
2022
- 2022-02-10 CN CN202210125108.8A patent/CN114461691B/en active Active
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109731334A (en) * | 2018-11-22 | 2019-05-10 | 腾讯科技(深圳)有限公司 | Switching method and apparatus, storage medium, the electronic device of state |
| CN109582398A (en) * | 2018-11-23 | 2019-04-05 | 阿里巴巴集团控股有限公司 | A kind of condition processing method, device and electronic equipment |
| CN112068810A (en) * | 2020-08-27 | 2020-12-11 | 北京五八信息技术有限公司 | Activity event processing method and device, electronic equipment and storage medium |
| CN112561057A (en) * | 2020-12-09 | 2021-03-26 | 清华大学 | State control method and device |
Cited By (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN114844711A (en) * | 2022-05-17 | 2022-08-02 | 北京经纬恒润科技股份有限公司 | A kind of vehicle Ethernet security state detection method and device |
| CN114844711B (en) * | 2022-05-17 | 2024-04-09 | 北京经纬恒润科技股份有限公司 | Method and device for detecting safety state of vehicle-mounted Ethernet |
| CN115756439A (en) * | 2022-10-20 | 2023-03-07 | 乾三(北京)科技有限公司 | State machine engine arrangement method and device and computer equipment |
| CN115756439B (en) * | 2022-10-20 | 2024-02-13 | 乾三(北京)科技有限公司 | Method and device for arranging state machine engine and computer equipment |
| WO2024176302A1 (en) * | 2023-02-20 | 2024-08-29 | 三菱電機株式会社 | State transition management device, state transition management method, and state transition management program |
| JP7614467B1 (en) | 2023-02-20 | 2025-01-15 | 三菱電機株式会社 | State transition management device, state transition management method, and state transition management program |
| CN116431801A (en) * | 2023-03-29 | 2023-07-14 | 魔方医药科技(苏州)有限公司 | Text matching method and device, electronic equipment and storage medium |
| CN117993905A (en) * | 2024-02-06 | 2024-05-07 | 易方达基金管理有限公司 | Instruction state machine-based repainting method and device |
Also Published As
| Publication number | Publication date |
|---|---|
| CN114461691B (en) | 2025-08-01 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN114461691A (en) | State machine control method, device, electronic device and storage medium | |
| KR102128139B1 (en) | File management with placeholders | |
| US7849179B2 (en) | System and program for managing devices in a network | |
| CN100541489C (en) | External metadata processing | |
| US20120266131A1 (en) | Automatic program generation device, method, and computer program | |
| US11768815B2 (en) | Determining when a change set was delivered to a workspace or stream and by whom | |
| US20170351506A1 (en) | Automating feature graduation | |
| CN112970011A (en) | Recording pedigrees in query optimization | |
| CN108270626A (en) | A kind of method, apparatus, equipment and the readable storage medium storing program for executing of upgrade server firmware | |
| JP2023553220A (en) | Process mining for multi-instance processes | |
| CN117270944A (en) | Version management method, device, computer equipment and medium of promt product | |
| WO2009033424A1 (en) | A method and system for obtaining information of user's commands and device for registering user's commands | |
| CN112130850A (en) | Method and device for implementing functions in application programs | |
| US10795687B2 (en) | Information processing system for setting hardware, method for setting hardware and non-transitory computer-readable storage medium recording program for setting hardware | |
| CN108255434B (en) | Label management method, management device and computer readable storage medium | |
| CN114116505A (en) | Code testing method and device | |
| CN112540889B (en) | Method, device, equipment and medium for adjusting hard disk starting sequence in user mode | |
| US11809833B2 (en) | System and method for image localization in knowledge base content | |
| CN110327626B (en) | Virtual server creation method and device | |
| CN111767222A (en) | Data model verification method, device, electronic device, storage medium | |
| CN113329103B (en) | Method and apparatus for executing commands for network devices | |
| CN111399841B (en) | Code processing method and device based on blockchain, storage medium and electronic equipment | |
| CN114691454A (en) | Process task processing method and device, computer equipment and storage medium | |
| CN119292946A (en) | Test case determination method, device, electronic device and storage medium | |
| CN118051213A (en) | Code input completion method, device, electronic equipment and storage medium |
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 | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |