Control Method, Device, Electronic Device and Storage Medium of State Machine

By receiving and parsing event information, the current state and target state transition function of the state machine are determined, thus solving the problem of complexity in state machine control and achieving simplified control without adding state classes.

CN114461691BActive Publication Date: 2025-08-01BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210125108.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-10
Publication Date
2025-08-01
Estimated Expiration
2042-02-10

AI Technical Summary

Technical Problem

In state machine control, when there are too many events and the state transitions are complex, it can easily lead to chaos. Existing technologies require the addition of new state classes to implement new states, which increases the complexity of control.

Method used

By receiving event handling instructions, parsing event information to determine the identifier and context, obtaining the target state transition function, and returning an event handling failure message when the current state does not match the starting state of the target state transition function, the addition of new state classes is avoided.

Benefits of technology

It simplifies the state machine control process, reduces control complexity, and avoids state class expansion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114461691B_ABST
    Figure CN114461691B_ABST
Patent Text Reader

Abstract

The present disclosure provides a control method, apparatus, electronic device and storage medium for a state machine, relating to the field of computer technology. The method includes: receiving an event processing instruction, where the event processing instruction includes event information to be processed; parsing the event information to determine an identifier of the event to be processed and context environment information; determining a target state transition function according to the identifier of the event to be processed; obtaining the current state of the state machine associated with the context environment information from a database; and returning an event processing failure message when the current state of the state machine does not match the start state corresponding to the target state transition function. Thus, without adding new state classes, etc., the control of the state machine can be achieved only based on the association relationship between events, thereby reducing the complexity of controlling the state machine and simplifying the process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technologies, and in particular, to a method and apparatus for controlling a state machine, an electronic device, and a storage medium. Background Art

[0002] With the development of computer technologies, state machines have become increasingly popular and are used more and more widely. In related technologies, during the process of controlling a state machine, each time a new state is added, a new state class needs to be implemented, and the behavior methods therein need to be implemented. When there are too many events and the state transitions are relatively complex, it is easy to cause confusion. Summary of the Invention

[0003] The present disclosure aims to at least partly solve one of the technical problems in the related technologies.

[0004] A first aspect embodiment of the present disclosure provides a method for controlling a state machine, including:

[0005] Receiving an event processing instruction, where the event processing instruction includes event information to be processed;

[0006] Parsing the event information to determine an identifier of the event to be processed and context environment information;

[0007] Determining a target state transition function according to the identifier of the event to be processed;

[0008] Obtaining a current state of the state machine associated with the context environment information from a database;

[0009] If the current state of the state machine does not match the start state corresponding to the target state transition function, returning a message indicating that the event processing fails.

[0010] A second aspect embodiment of the present disclosure provides a device for controlling a state machine, including:

[0011] A receiving module, configured to receive an event processing instruction, where the event processing instruction includes event information to be processed;

[0012] An analysis module, configured to parse the event information to determine an identifier of the event to be processed and context environment information;

[0013] A determination module, configured to determine a target state transition function according to the identifier of the event to be processed;

[0014] An obtaining module, configured to obtain a current state of the state machine associated with the context environment information from a database;

[0015] The return module is used to return an event processing failure message when the current state of the state machine does not match the start state corresponding to the target state transfer function.

[0016] The third embodiment of the present disclosure proposes an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the control method of the state machine proposed in the first embodiment of the present disclosure is implemented.

[0017] The fourth embodiment of the present disclosure proposes a non-temporary computer-readable storage medium storing a computer program, which, when executed by a processor, implements the control method of the state machine proposed in the first embodiment of the present disclosure.

[0018] The fifth embodiment of the present disclosure proposes a computer program product. When the instruction processor in the computer program product is executed, the control method of the state machine proposed in the first embodiment of the present disclosure is executed.

[0019] The control method, device, electronic device and storage medium of the state machine provided by the present disclosure can 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 environment information of the event to be processed, and determine the target state transfer function according to the identifier of the event to be processed, and then obtain the current state of the state machine associated with the context environment information from the database, and return an event processing failure message when the current state of the state machine does not match the start state corresponding to the target state transfer function. Thus, by parsing the received event information, the identifier, target state transfer function and context environment information of the event to be processed can be determined, so that when controlling the state machine, there is no need to add a new state class, etc., and the control of the state machine can be achieved only based on the association relationship between events, thereby reducing the complexity of state machine control and simplifying the process.

[0020] Additional aspects and advantages of the present disclosure will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The above and / or additional aspects and advantages of the present disclosure will become apparent and readily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0022] Figure 1 A flowchart of a state machine according to an embodiment of the present disclosure;

[0023] Figure 2 A flow chart of a method for controlling a state machine according to an embodiment of the present disclosure;

[0024] Figure 3 Flow schematic diagram of the control method of the state machine provided by an embodiment of the present disclosure;

[0025] Figure 4 Flow schematic diagram of the control method of the state machine provided by an embodiment of the present disclosure;

[0026] Figure 5 Structural schematic diagram of the control device of the state machine provided by another embodiment of the present disclosure;

[0027] Figure 6 Block diagram of an exemplary electronic device suitable for implementing the embodiments of the present disclosure is shown. Detailed implementation manners

[0028] Embodiments of the present disclosure will be described in detail below. Examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals denote 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 to the present disclosure.

[0029] The control method, device, electronic device, and storage medium of the state machine according to the embodiments of the present disclosure will be described below with reference to the accompanying drawings.

[0030] The embodiments of the present disclosure are exemplified by the control method of the state machine being configured in the control device of the state machine. The control device of the state machine can be applied to any electronic device so that the electronic device can execute the control function of the state machine.

[0031] Optionally, the execution subject in the present disclosure may also be a state machine configured with the control method of the state machine, and the present disclosure does not limit this.

[0032] Among them, the electronic device may be a 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., which are hardware devices with various operating systems, touch screens, and / or display screens.

[0033] First, a brief description of the state machine provided in the present disclosure will be given.

[0034] In the present disclosure, the object-oriented finite state machine M can be defined as a seven-tuple, with C introduced as the state machine context environment information and A introduced as the state machine behavior, which can be expressed as follows: M = (S, C, E, δ, δ0, F, A).

[0035] Among them, the state, which can be abbreviated as S = {s0, s1,..., si}, which 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 briefly denoted as C.

[0036] An event, which can be briefly denoted as E = {e0, e1, …, e i}, which can represent a set of finite events. State transitions can be triggered by events.

[0037] δ can represent the state transition function: That is It can be understood that event e triggers the transition of state s to s' under the context information c, and at the same time, the state machine executes behavior a, and the context information is c'.

[0038] S0 ∈ S can represent the initial state of the state machine, which is a subset of S; F ∈ S can represent the termination state of the state machine, which is a subset of S.

[0039] The action of the state machine, which can be briefly denoted as A. This action can be determined according to the operations, attributes, and links of the context object, as well as the parameters of the triggering event or any other features visible within its scope, used to respond to events, maintain the robustness of the state machine, or implement more complex logics. For example, it can be event state transition and event logging, or making changes to the current environment, etc. The present disclosure does not make any limitations in this regard.

[0040] Next, take Figure 1 as an example to briefly illustrate the usage process of the state machine provided by the present disclosure.

[0041] Such as Figure 1 shown. First, states, events, and state machine actions can be defined, then it is confirmed whether context information is needed. If context information is needed, context can be customized. If context information is not needed, the default context can be used. After that, a state machine transition instance can be created. Next, the state transition function can be designed and the state transition rules can be constructed. Then, the state machine can be used.

[0042] It should be noted that the above example is only illustrative and cannot be used as a limitation on the usage process of the state machine in the embodiments of the present disclosure.

[0043] Figure 2 is a schematic flow diagram of the control method of the state machine provided by the embodiments of the present disclosure.

[0044] Such as Figure 2 shown, the control method of this state machine can include the following steps:

[0045] Step 201: Receive an event processing instruction, where the event processing instruction includes event information to be processed.

[0046] Among them, the event processing instruction can be instruction information sent by the client where the user is located, which can be an instruction in voice form or in other forms; for example, when it is detected that a corresponding control is triggered, it is determined to receive the event processing instruction. The present disclosure does not make any limitations in this regard.

[0047] In addition, after receiving the event processing instruction, by analyzing and processing the event processing instruction, the event information to be processed included therein can be determined. The present disclosure does not make any limitations in this regard.

[0048] It can be understood that in the embodiments of the present disclosure, any desirable method can be adopted to analyze and process the received event processing instruction. The present disclosure does not make any limitations in this regard.

[0049] Step 202: Parse the event information to be processed to determine the identifier and context environment information of the event to be processed.

[0050] Among them, the style or presentation form of the identifier of the event to be processed can be set in advance. The present disclosure does not make any limitations in this regard.

[0051] In addition, the context environment information can include the business scenario, business identifier, etc. of the event to be processed. The present disclosure does not make any limitations in this regard.

[0052] It can be understood that the style or presentation form of the business identifier can be set in advance. For example, for the "arbitration business", its corresponding business identifier can be "arbitration", or it can also be "ZC", etc., which can uniquely represent the business. The present disclosure does not make any limitations in this regard.

[0053] For example, by parsing the event information to be processed, if it is determined that it includes "the auditor requests the user to supplement materials, arbitration", then it can be determined that the identifier of the event to be processed is: the auditor requests the user to supplement materials; the business scenario included in the context environment information is: business arbitration.

[0054] It should be noted that the above examples are only illustrative and cannot be used as limitations on the identifier of the event to be processed, context environment information, etc. in the embodiments of the present disclosure.

[0055] Step 203: Determine the target state transition function according to the identifier of the event to be processed.

[0056] It can be understood that for different events, their corresponding target state transition functions may be the same or may be different. The present disclosure does not make any limitations in this regard.

[0057] Optionally, the correspondence between different events and state transition functions can be set in advance. After that, according to the identifier of the event to be processed, the target state transition function corresponding to the event identifier can be selected from the correspondence between events and state transition functions.

[0058] For example, it is 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 it is determined through parsing the event information to be processed that the identifier of the event to be processed is "3", then it can be determined that it is event 3. After that, by looking up the correspondence between events and state transition functions, the corresponding target state transition function can be determined as δ3.

[0059] It should be noted that the above example is only illustrative and cannot be used as a limitation on the identifier of the event to be processed, the target state transition function, etc. in the embodiments of the present disclosure.

[0060] Step 204, obtain the current state of the state machine associated with the context environment information from the database.

[0061] Among them, the state machine can have a corresponding relationship with the event to be processed. The present disclosure does not make any limitations on this.

[0062] It can be understood that there can be multiple records of state machines stored in the database. Therefore, in order to improve the accuracy of event processing, the current state of the state machine associated with the context environment information can be obtained from the database.

[0063] For example, if the determined context environment information is: an arbitration service initiated by user A. After that, a search can be conducted in the database to determine the current state of the state machine associated with "the arbitration service initiated by user A". If it is found in the database that the information associated with "the arbitration service initiated by user A" is: User A initiated an arbitration appeal (February 10th); The reviewer accepted it (February 11th). Then it can be determined that the current state of the state machine associated with "the arbitration service initiated by user A" is: The reviewer accepted it.

[0064] It should be noted that the above example is only illustrative and cannot be used as a limitation on the context environment information and its associated current state of the state machine in the embodiments of the present disclosure.

[0065] Step 205, if the current state of the state machine does not match the start state corresponding to the target state transition function, return a message indicating that the event processing fails.

[0066] 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. At this time, an event processing failure message can be returned, that is, the state machine is not controlled.

[0067] In addition, the event processing failure message can be any information that can represent the failure of event processing. For example, it can be set in advance that "0" represents the failure of event processing. If it is determined that the current state of the state machine does not match the start state corresponding to the target state transition function, "0" can be returned. Or, a prompt of "event processing failed" can also be returned, etc. The present disclosure does not limit this.

[0068] For example, if the current state of the state machine is "the user has completed supplementary information" and the start state corresponding to the target state transition function is "the reviewer requests the user to supplement information", and the two are inconsistent, 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 thus an event processing failure message can be returned.

[0069] It should be noted that the above examples are only illustrative and cannot be used as a limitation on the current state of the state machine, the start state corresponding to the target state transition function, etc. in the embodiments of the present disclosure.

[0070] In the embodiments of the present disclosure, an event processing instruction can be received first, where the event processing instruction includes the event information to be processed. Then, the event information to be processed is parsed to determine the identifier and context environment information of the event to be processed. According to the identifier of the event to be processed, the target state transition function is determined. Then, the current state of the state machine associated with the context environment information can be obtained from the database. In the case where 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. Thus, by parsing the received event information, the identifier of the event to be processed, the target state transition function, and the context environment information can be determined. Therefore, when controlling the state machine, there is no need to add new state classes, etc. Only based on the association relationship between events, the control of the state machine can be realized, thereby reducing the complexity of controlling the state machine and simplifying the process.

[0071] Figure 3 It is a schematic flowchart of the control method of the state machine provided by the embodiments of the present disclosure. As Figure 3 shown, the control method of the state machine can include the following steps:

[0072] Step 301, receive an event processing instruction, where the event processing instruction includes the event information to be processed.

[0073] Step 302, parse the event information to determine the identifier and context environment information of the event to be processed.

[0074] Step 303: Obtain the attribute information of the event to be processed according to the identifier of the event to be processed.

[0075] Among them, the attribute information of the event to be processed may include the state transition function, initial state, end state, etc. corresponding to the event to be processed. The present disclosure does not limit this.

[0076] It can be understood that the attribute information corresponding to each event to be processed can be set in advance, so that after determining the identifier of the event to be processed, the corresponding attribute information can be determined according to this identifier.

[0077] Step 304: Determine the state transition function in the attribute information of the event to be processed as the target state transition function.

[0078] 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 this identifier "Event 1", its corresponding attribute information can be determined as: The initial state is: s1, the end state is: s1', so the state transition function δ1 in the attribute information can be determined as the target state transition function.

[0079] It should be noted that the above examples are only illustrative and cannot be used as a limitation on the identifier of the event to be processed, the corresponding attribute information, the state transition function, etc. in the embodiments of the present disclosure.

[0080] Step 305: Obtain the state transition record associated with the context information from the database.

[0081] Among them, the state transition record may refer to the historical state change information of the current business, that is, the event to be processed. The present disclosure does not limit this.

[0082] It can be understood that for any business or event, each time it is processed, the processing process will be recorded, that is, the initial state and target state corresponding to the processing process will be saved in the database. If the event is subsequently processed again, the state transition record corresponding to the event in the database can be updated and saved.

[0083] Step 306: Determine the target state in the state transition record as the current state of the state machine.

[0084] Among them, the target state in the state transition record can be understood as the latest state or the state at the most recent moment in the state transition record. For example, if the state transition record is: the user initiates an appeal arbitration - the reviewer accepts it - the reviewer requests the user to supplement materials - the user completes the material supplement, then it can be determined that the target state in the state transition record is: the user completes the material supplement. The present disclosure does not make any limitations in this regard.

[0085] For example, the context information is: the appeal arbitration initiated by user B. Subsequently, the state transition record associated with "the appeal arbitration initiated by user B" can be searched in the database. If the found state transition record is: user B initiates an appeal arbitration - reviewer C accepts it - reviewer C requests user B to supplement materials, then it can be determined that the target state is "reviewer C requests user B to supplement materials", and subsequently, it can be determined that the current state of the state machine is: reviewer C requests user B to supplement materials.

[0086] It should be noted that the above examples are only illustrative and cannot be used as limitations on the context information, its associated state transition record, and the target state in the state transition record in the embodiments of the present disclosure.

[0087] Step 307, in the case where the current state of the state machine does not match the start state corresponding to the target state transition function, return an event processing failure message.

[0088] Step 308, in the case where the current state of the state machine matches the start state corresponding to the target state transition function, determine the transfer condition corresponding to the event to be processed.

[0089] It can be understood that if the current state of the state machine is the same as the start state corresponding to the target state transition function, then it can be considered that the current state of the state machine matches the start state corresponding to the target state transition function.

[0090] For example, the current state of the state machine is "the user completes supplementing materials", and the start state corresponding to the target state transition function is "the user completes the material supplement", and the two are the same, so it can be considered that the current state of the state machine matches the start state corresponding to the target state transition function, and subsequently, the transfer condition corresponding to the event to be processed can be determined. The present disclosure does not make any limitations in this regard.

[0091] In addition, the transfer condition corresponding to the event to be processed can be set by itself when defining the event, or can also be set according to rules, or can also be default conditions, etc. The present disclosure does not make any limitations in this regard.

[0092] For example, the transfer condition a1 required for event 1 to transfer from the start state A corresponding to the target state transition function to the end state B can be set in advance; the transfer condition a2 required for event 2 to transfer from the start state C corresponding to the target state transition function to the end state D; and the transfer condition a3 required for event 3 to transfer 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 start state A corresponding to the target transfer function, the transfer condition corresponding to the event 1 to be processed can be determined as: a1.

[0093] It should be noted that the above examples are only illustrative and cannot be used as a limitation on the transfer conditions, etc. corresponding to the event to be processed in the embodiments of the present disclosure.

[0094] Step 309, when the current condition of the state machine meets the transfer condition, transfer the state machine from the current state to the end state corresponding to the target transfer function.

[0095] For example, if the current state of the event 1 to be processed matches the start state "the auditor requests user A to supplement information" corresponding to the target transfer function, the determined transfer condition is: the information has been supplemented. If the current user A has supplemented the relevant information, it can be determined that the current condition of the state machine meets the corresponding transfer condition, and then the state machine can be transferred from the current state "the auditor requests user A to supplement information" to the end state "user completes supplementing information" corresponding to the target transfer function.

[0096] It should be noted that the above examples are only illustrative and cannot be used as a limitation on the current condition of the state machine, the transfer condition, and the end state corresponding to the target transfer function in the implementation of the present disclosure.

[0097] In an embodiment of the present disclosure, an event processing instruction may be received first. The event processing instruction includes event information to be processed. Then, the event information is parsed to determine the identifier and context environment information of the event to be processed. Next, according to the identifier of the event to be processed, the attribute information of the event to be processed is obtained. Then, the state transition function in the attribute information of the event to be processed can be determined as the target state transition function, and a state transition record associated with the context environment information is obtained from the database. Then, the target state in the state transition record can be determined as the current state of the state machine. In the case where 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. In the case where the current state of the state machine matches the start state corresponding to the target state transition function, the transfer condition corresponding to the event to be processed is determined. When the current condition of the state machine satisfies the transfer condition, the state machine is transferred from the current state to the end state corresponding to the target transfer function. Thus, after parsing 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 environment information. Then, according to the matching situation between the current state of the state machine and the start state corresponding to the target state transition function, the control of the state machine can be realized. This process does not require adding new state classes, etc., avoiding problems such as class inflation, thereby reducing the complexity of controlling the state machine and simplifying the process.

[0098] Figure 4 It is a schematic flowchart of the control method for the state machine provided by the embodiment of the present disclosure. As Figure 4 shown, the control method for the state machine may include the following steps:

[0099] Step 401: Receive an event processing instruction, where the event processing instruction includes event information to be processed.

[0100] Step 402: Parse the event information to determine the identifier and context environment information of the event to be processed.

[0101] Step 403: Determine the target state transition function according to the identifier of the event to be processed.

[0102] Step 404: Obtain the current state of the state machine associated with the context environment information from the database.

[0103] Step 405: Determine the transfer condition corresponding to the event to be processed when the current state of the state machine matches the start state corresponding to the target state transition function.

[0104] Step 406: Transfer the state machine from the current state to the end state corresponding to the target transfer function when the current condition of the state machine satisfies the transfer condition.

[0105] It should be noted that for the specific content and implementation methods of steps 401 to 406, reference can be made to the descriptions of other embodiments of the present disclosure, and details will not be elaborated here.

[0106] Step 407: Generate and temporarily store the current state transition record according to the current state and the end state.

[0107] For example, if the current state is "user completes result confirmation" and the end state is "administrator operation completed", the generated current state transition record can be: user completes result confirmation - administrator operation completed; then this state transition record can be temporarily stored.

[0108] Or, if the state transition record obtained from the database is "user initiates appeal arbitration - reviewer accepts - reviewer requests user to supplement materials"; the current state of the state machine is "reviewer requests user to supplement materials" and the end state is "user completes material supplementation", then the generated current state transition record can be: "user initiates appeal arbitration - reviewer accepts - reviewer requests user to supplement materials - user completes material supplementation", and then this state transition record can be temporarily stored.

[0109] It should be noted that the above examples are only illustrative and cannot be used as a limitation on the current state, end state, and current state transition record, etc. in the embodiments of the present disclosure.

[0110] Step 408: Determine the value of the version number of the state transition record associated with the event information to be processed in the database.

[0111] Among them, 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 available value, which is not limited in the present disclosure.

[0112] 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 event information to be processed.

[0113] For example, if the name of the state transition record associated with the event information to be processed contains "NO.1", then it can be determined that the value of the version number of the state transition record is 1. This is not limited in the present disclosure.

[0114] Step 409: When the value of the version number is less than the threshold, update the state transition record associated with the event information to be processed in the database according to the temporarily stored state transition record, and increment the value of the version number by one.

[0115] Among them, the threshold can be a pre-set value, which is not limited in the present disclosure.

[0116] For example, if the set threshold is 1, the current version number is 0, the temporarily stored state transition record is "The reviewer requests the user to supplement materials - the user completes the supplementary materials", and the state transition record associated with the event information to be processed in the database is "The user initiates an appeal arbitration - the reviewer accepts - the reviewer requests the user to supplement materials". Since the current version number is less than the set threshold, the state transition record associated with the event information to be processed in the database can be updated. The updated state transition record can be "The user initiates an appeal arbitration - the reviewer accepts - the reviewer requests the user to supplement materials - the user completes the supplementary materials". After that, the value of the version number can be incremented by one, and the updated version number can be 1.

[0117] It should be noted that the above examples are for illustrative purposes only and cannot be used as a limitation on the version number value, threshold, state transition record, etc. in the embodiments of the present disclosure.

[0118] Optionally, when the value of the version number is equal to the threshold, the current state transition record is deleted.

[0119] For example, if the set threshold is 1, the current version number is 1, and the currently temporarily stored state transition record is "The reviewer requests the user to supplement materials - the user completes the supplementary materials", then the current state transition record can be deleted. The present disclosure does not make any limitations in this regard.

[0120] 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. To avoid duplicate processing of the event, the temporarily stored state transition record can be deleted, thereby ensuring the accuracy and reliability of event processing and state machine control.

[0121] For example, within a relatively short continuous period, the same event processing instruction is received multiple times. If state machine 1 first executes the event to be processed, stores the associated state transition record in the database, and updates the corresponding version number to 1. If state machine 2 is also executing the event to be processed, after generating the current state transition record, it can first determine the version number of the state transition record of this event in the database. If it is determined that the version number is 1 and the set threshold is also 1, and the two are equal, then state machine 2 can delete its corresponding temporarily stored state transition record.

[0122] It should be noted that the above examples are for illustrative purposes only and cannot be used as a limitation on the version number of the state transition record, threshold, etc. in the embodiments of the present disclosure.

[0123] In an 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 transfer function. After that, according to the current state and the end state, the current state transfer record can be generated and temporarily stored, and the value of the version number of the state transfer record associated with the event information to be processed in the database can be determined. When the value of the version number is less than the threshold, the state transfer record associated with the event information to be processed in the database is updated according to the temporarily stored state transfer record, and the value of the version number is incremented by one. Thus, the current state transfer record can be generated and temporarily stored according to the current state and the end state of the state machine first, and then when the value of the version number of the associated state transfer function in the database is less than the threshold, the associated state transfer record in the database can be updated according to the temporarily stored state transfer record. This process does not require adding new state classes, etc., and the control of the state machine can be realized only according to the association relationship between events, thereby reducing the complexity of controlling the state machine and simplifying the process.

[0124] To implement the above embodiment, the present disclosure also proposes a control device for a state machine.

[0125] Figure 5 It is a schematic structural diagram of the control device for the state machine provided by the embodiment of the present disclosure.

[0126] As Figure 5 shown, the control device 100 of the state machine may include: a receiving module 110, a parsing module 120, a determining module 130, an obtaining module 140, and a returning module 150.

[0127] Among them, the receiving module 110 is configured to receive an event processing instruction, where the event processing instruction includes event information to be processed.

[0128] The parsing module 120 is configured to parse the event information to determine the identifier and context environment information of the event to be processed.

[0129] The determining module 130 is configured to determine a target state transfer function according to the identifier of the event to be processed.

[0130] The obtaining module 140 is configured to obtain the current state of the state machine associated with the context environment information from the database.

[0131] The returning module 150 is configured to return an event processing failure message when the current state of the state machine does not match the start state corresponding to the target state transfer function.

[0132] Optionally, the determining module 130 is specifically configured to:

[0133] Obtain the attribute information of the event to be processed according to the identifier of the event to be processed;

[0134] Determine the state transition function in the attribute information of the event to be processed as the target state transition function.

[0135] Optionally, the obtaining module 140 is specifically configured to:

[0136] Obtain a state transition record associated with the context environment information from the database;

[0137] Determine the target state in the state transition record as the current state of the state machine.

[0138] Optionally, the determining module 130 is further configured to:

[0139] Determine the transfer condition corresponding to the event to be processed when the current state of the state machine matches the start state corresponding to the target state transition function;

[0140] When the current condition of the state machine satisfies the transfer condition, transfer the state machine from the current state to the end state corresponding to the target transfer function.

[0141] Optionally, the determining module 130 is further configured to:

[0142] Generate and temporarily store the current state transition record according to the current state and the end state;

[0143] Determine the value of the version number of the state transition record associated with the event information to be processed in the database;

[0144] When the value of the version number is less than the threshold, update the state transition record associated with the event information to be processed in the database according to the temporarily stored state transition record, and increment the value of the version number by one.

[0145] Optionally, the determining module 130 is further configured to:

[0146] Delete the current state transition record when the value of the version number is equal to the threshold.

[0147] For the functions and specific implementation principles of the above-mentioned modules in the embodiments of the present disclosure, reference may be made to the above-mentioned method embodiments, which will not be elaborated here.

[0148] The control device of the state machine according to the embodiments of the present disclosure may first receive an event processing instruction, where the event processing instruction includes event information to be processed. Then, the event information to be processed is parsed to determine the identifier and context information of the event to be processed. According to the identifier of the event to be processed, a target state transition function is determined. 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 start state corresponding to the target state transition function, an event processing failure message is returned. Thus, by parsing the received event information, the identifier of the event to be processed, the target state transition function, and the context information can be determined. Therefore, when controlling the state machine, there is no need to add new state classes, etc. Only according to the association relationship between events, the control of the state machine can be realized, thereby reducing the complexity of controlling the state machine and simplifying the process.

[0149] To implement the above embodiments, the present disclosure also proposes an electronic device, including: a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the control method of the state machine as proposed in the foregoing embodiments of the present disclosure is implemented.

[0150] To implement the above embodiments, the present disclosure also proposes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the control method of the state machine as proposed in the foregoing embodiments of the present disclosure is implemented.

[0151] To implement the above embodiments, the present disclosure also proposes a computer program product, and when the instruction processor in the computer program product executes, the control method of the state machine as proposed in the foregoing embodiments of the present disclosure is executed.

[0152] Figure 6 The block diagram of an exemplary electronic device suitable for implementing the embodiments of the present disclosure is shown. Figure 6 The shown electronic device 12 is only an example and should not impose any limitation on the functions and usage scope of the embodiments of the present disclosure.

[0153] As Figure 6 shown, the electronic device 12 is presented in the form of a general-purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 connecting different system components (including the system memory 28 and the processing unit 16).

[0154] Bus 18 represents one or more of several types of bus architectures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of the various bus architectures. By way of example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnection (PCI) bus.

[0155] Electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by electronic device 12, including volatile and nonvolatile media, removable and non-removable media.

[0156] Memory 28 can include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Electronic device 12 can further include other removable / non-removable, volatile / nonvolatile computer system storage media. By way of example only, storage system 34 can be used for reading and writing on non-removable, nonvolatile magnetic media ( Figure 6 not shown, typically referred to as a "hard disk drive"). Although Figure 6 not shown in the figure, a disk drive for reading and writing on a removable nonvolatile disk (such as a "floppy disk") and an optical disk drive for reading and writing on a removable nonvolatile optical disk (such as: Compact Disc Read Only Memory (CD-ROM), Digital Video Disc Read Only Memory (DVD-ROM), or other optical media) can be provided. In these cases, each drive can be connected to bus 18 through one or more data media interfaces. Memory 28 can include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of the present disclosure.

[0157] A program / utilities 40 having a set (at least one) of program modules 42 can be stored, for example, in a memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. The program modules 42 generally execute the functions and / or methods in the embodiments described in this disclosure.

[0158] The electronic device 12 can also communicate with one or more external devices 14 (such as a keyboard, a pointing device, a display 24, etc.), and can also communicate with one or more devices that enable a user to interact with the electronic device 12, and / or communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (such as a network card, a modem, etc.). Such communication can be carried out through an input / output (I / O) interface 22. Moreover, the electronic device 12 can also communicate with one or more networks (such as a Local Area Network (LAN), a Wide Area Network (WAN), and / or a public network, such as the Internet) through a network adapter 20. As shown in the figure, the network adapter 20 communicates with other modules of the electronic device 12 through a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in combination with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.

[0159] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the methods mentioned in the foregoing embodiments.

[0160] For the technical solution of this disclosure, an event processing instruction can be received first. Among them, the event processing instruction includes the event information to be processed. Then, the event information to be processed is parsed to determine the identifier and context environment information of the event to be processed. According to the identifier of the event to be processed, a target state transition function is determined. Then, the current state of the state machine associated with the context environment information can be obtained from the database. In the case where 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. Thus, by parsing the received event information, the identifier of the event to be processed, the target state transition function, and the context environment information can be determined. Therefore, when controlling the state machine, there is no need to add new state classes, etc. Only based on the association relationship between events, the control of the state machine can be realized, thereby reducing the complexity of controlling the state machine and simplifying the process.

[0161] In the description of this specification, the descriptions referring to terms such as "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" etc. mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present disclosure. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.

[0162] In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include at least one of such features. In the description of the present disclosure, "a plurality of" means at least two, such as two, three, etc., unless otherwise specifically defined.

[0163] Any process or method description shown in the flowchart or described in other ways herein can be understood as representing a module, segment, or part of code including one or more executable instructions for implementing a customized logic function or process, and the scope of the preferred embodiments of the present disclosure includes additional implementations, where the functions can be executed in a substantially simultaneous manner or in a reverse order according to the functions involved, rather than in the order shown or discussed, which should be understood by those skilled in the art to which the embodiments of the present disclosure pertain.

[0164] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a definitional sequence list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or in conjunction with these instruction execution systems, apparatus, or devices. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection portion having one or more wirings (electronic device), a portable computer diskette (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpretation, or otherwise processing as appropriate, and then storing it in a computer memory.

[0165] It should be understood that various parts of the present disclosure can be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or a combination of the following techniques well known in the art can be used: discrete logic circuits having logic gate circuits for implementing logical functions on data signals, application-specific integrated circuits having appropriate combinational logic gate circuits, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.

[0166] Those of ordinary skill in the art of this technology can understand that all or part of the steps carried by the method of implementing the above embodiments can be completed by a program instructing relevant hardware, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.

[0167] In addition, each functional unit in various embodiments of the present disclosure may be integrated into one processing module, may exist physically alone for each unit, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. When the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.

[0168] The above-mentioned storage medium may be a read-only memory, a magnetic disk, an optical disc, etc. Although the embodiments of the present disclosure have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting the present disclosure. Those of ordinary skill in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present disclosure.

Claims

1. A control method for a state machine, characterized in that, including: Receiving an event processing instruction, where the event processing instruction includes event information to be processed; Parsing the event information to determine the identifier and context environment information of the event to be processed; Determining a target state transition function according to the identifier of the event to be processed; Obtaining the current state of the state machine associated with the context environment information from a database; Returning an event processing failure message if the current state of the state machine does not match the start state corresponding to the target state transition function; The obtaining the current state of the state machine associated with the context environment information from the database includes: Obtaining a state transition record associated with the context environment information from the database; Determining the target state in the state transition record as the current state of the state machine; After obtaining the current state of the state machine associated with the context environment information from the database, further including: Determining the transfer condition corresponding to the event to be processed if the current state of the state machine matches the start state corresponding to the target state transition function; Transferring the state machine from the current state to the end state corresponding to the target transfer function if the current condition of the state machine satisfies the transfer condition.

2. The method according to claim 1, wherein The determining the target state transition function according to the identifier of the event to be processed includes: Obtaining the attribute information of the event to be processed according to the identifier of the event to be processed; Determining the state transition function in the attribute information of the event to be processed as the target state transition function.

3. The method according to claim 1, wherein After transferring the state machine from the current state to the end state corresponding to the target transfer function, further including: Generating and temporarily storing a current state transition record according to the current state and the end state; Determining the value of the version number of the state transition record associated with the event information to be processed in the database; Updating the state transition record associated with the event information to be processed in the database according to the temporarily stored state transition record and incrementing the value of the version number by one if the value of the version number is less than a threshold; 4. The method according to claim 3, wherein After determining the value of the version number of the state transition record associated with the event information to be processed in the database, further including: Deleting the current state transition record if the value of the version number is equal to the threshold.

5. A control device for a state machine, characterized in that, including: A receiving module for receiving an event processing instruction, where the event processing instruction includes event information to be processed; A parsing module for parsing the event information to determine the identifier and context environment information of the event to be processed; A determining module for determining a target state transition function according to the identifier of the event to be processed; An obtaining module for obtaining the current state of the state machine associated with the context environment information from a database; A returning module for returning an event processing failure message if the current state of the state machine does not match the start state corresponding to the target state transition function; The obtaining module is further configured to: obtain a state transition record associated with the context environment information from the database; determine the target state in the state transition record as the current state of the state machine. The determining module is further configured to determine a transfer condition corresponding to the to-be-processed event when the current state of the state machine matches the start state corresponding to the target state transition function; and transfer the state machine from the current state to the end state corresponding to the target transfer function when the condition of the state machine currently satisfies the transfer condition.

6. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, it implements the control method of the state machine according to any one of claims 1-4.

7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the control method of the state machine according to any one of claims 1-4.

8. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the control method of the state machine according to any one of claims 1-4.

Citation Information

Patent Citations

  • Activity event processing method and device, electronic equipment and storage medium

    CN112068810A