State machine processing, state processing method, device, electronic device and storage medium
By defining global and individual states within a state machine, a hierarchical finite state machine is constructed, which solves the problems of high complexity and high maintenance cost of state machines, and achieves more efficient state management and flexibility.
Patent Information
- Application Number
- CN202110594974.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-28
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2041-05-28
AI Technical Summary
Existing state machine management methods result in high complexity, high development and maintenance costs, and poor flexibility in state control.
By determining the global state and individual state from all states of the state-handling object, a set of local states is obtained, and a sub-state machine is constructed. Finally, a hierarchical finite state machine is constructed to manage the state.
It reduces the complexity of state machines and states, decreases development and maintenance costs, and improves the flexibility of state machines in managing states.
Smart Images

Figure CN113326083B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to artificial intelligence fields such as computer technology and Internet of Vehicles. Background Art
[0002] State machines are widely used in the computer field, and many systems use state machines. The state machine consists of a set of nodes (states) and a set of corresponding transfer functions, which define multiple states and the transition between states. Among the multiple defined states, there is at least one initial state and at least one final state. The state machine starts running from the initial state, and when it migrates to the final state, the state machine stops running. When a trigger event is received, the state machine uses its own state parsing module to parse its current state. The state machine uses its own control module to control the jump between the corresponding state nodes according to the received trigger event and the current state, so as to realize the state machine jumping to the next state. It can be seen that how to design a reasonable state machine for different state definitions is extremely important for the state management performance. Summary of the invention
[0003] The embodiments of the present disclosure provide a state machine processing, a state processing method, an apparatus, an electronic device, and a storage medium, which can reduce the complexity of the state machine and each state, reduce the development and maintenance costs of the state machine, and improve the flexibility of the state machine in state control.
[0004] In a first aspect, an embodiment of the present disclosure provides a state machine processing method, including:
[0005] Determine the global state and the individual state from all the states of the state processing object;
[0006] Classifying each of the monomer states to obtain at least one local state set;
[0007] Constructing a sub-state machine for each of the local state sets; wherein each of the sub-state machines manages a single state in the local state set;
[0008] A hierarchical finite state machine is constructed according to each of the sub-state machines and the global state.
[0009] In a second aspect, an embodiment of the present disclosure provides a state processing method, including:
[0010] Determine the state triggering event of the state processing object;
[0011] Responding to the state triggering event according to the state triggering event and the hierarchical finite state machine of the state processing object; wherein the hierarchical finite state machine is constructed by the state machine processing method described in the first aspect;
[0012] The current update state is determined according to the response result of the state triggering event.
[0013] In a third aspect, an embodiment of the present disclosure provides a state machine processing device, including:
[0014] A state determination module, used for determining a global state and a single state from all states of a state processing object;
[0015] A monomer state classification module, used for classifying each of the monomer states to obtain at least one local state set;
[0016] A sub-state machine construction module, used to construct a sub-state machine for each of the local state sets; wherein each of the sub-state machines manages a single state in the local state set;
[0017] The hierarchical finite state machine construction module is used to construct a hierarchical finite state machine according to each of the sub-state machines and the global state.
[0018] In a fourth aspect, an embodiment of the present disclosure provides a state processing device, including:
[0019] A state triggering event determination module, used to determine the state triggering event of the state processing object;
[0020] A state triggering event response module, used to respond to the state triggering event according to the state triggering event and the hierarchical finite state machine of the state processing object; wherein the hierarchical finite state machine is constructed by the state machine processing method according to any one of claims 1 to 7;
[0021] The current update state determination module is used to determine the current update state according to the response result of the state triggering event.
[0022] In a fifth aspect, an embodiment of the present disclosure provides an electronic device, including:
[0023] at least one processor; and
[0024] a memory communicatively connected to the at least one processor; wherein,
[0025] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the state machine processing method provided by the first aspect embodiment or the state processing method provided by the second aspect embodiment.
[0026] In the sixth aspect, the embodiments of the present disclosure further provide a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute the state machine processing method provided in the first aspect embodiment or the state processing method provided in the second aspect embodiment.
[0027] In the seventh aspect, the embodiments of the present disclosure further provide a computer program product, including a computer program, which, when executed by a processor, implements the state machine processing method provided in the embodiment of the first aspect or the state processing method provided in the embodiment of the second aspect.
[0028] The disclosed embodiment determines the global state and the monomer state from all the states of the state processing object, classifies each monomer state to obtain at least one local state set, and constructs a sub-state machine that can manage the monomer state in the local state set for each local state set, thereby constructing a hierarchical finite state machine according to each sub-state machine and the global state. After the hierarchical finite state machine is constructed, when the state triggering event of the state processing object is determined, the state triggering event can be responded to according to the state triggering event and the hierarchical finite state machine of the state processing object, and the current update state is determined according to the response result of the state triggering event, so as to solve the problems existing in the existing state management method, such as the high complexity of the state machine and each state, the high cost of state machine development and maintenance, and the poor flexibility of state control, thereby reducing the complexity of the state machine and each state, reducing the development and maintenance cost of the state machine, and improving the flexibility of the state machine for state control.
[0029] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0031] Figure 1 It is a schematic diagram of the effect of the finite state machine of the Bluetooth phone in the prior art managing some states;
[0032] Figure 2 is a flow chart of a state machine processing method provided by an embodiment of the present disclosure;
[0033] Figure 3 is a flow chart of a state machine processing method provided by an embodiment of the present disclosure;
[0034] Figure 4 It is a structural diagram of a hierarchical finite state machine of a Bluetooth telephone device provided by an embodiment of the present disclosure;
[0035] Figure 5 is a flow chart of a state processing method provided by an embodiment of the present disclosure;
[0036] Figure 6 is a flow chart of a state machine processing method provided by an embodiment of the present disclosure;
[0037] Figure 7 is a structural diagram of a state machine processing device provided by an embodiment of the present disclosure;
[0038] Figure 8 is a structural diagram of a state machine processing device provided by an embodiment of the present disclosure;
[0039] Fig. 9 It is a structural diagram of an electronic device used to implement the state machine processing method or state processing method of an embodiment of the present disclosure. DETAILED DESCRIPTION
[0040] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0041] In the prior art, different state machine control methods need to be designed for different state definitions, and all state controls are basically managed by a large and comprehensive state machine, resulting in extremely complex state changes presented by the final state machine. This state machine processing method has an obvious defect: when a global impact event (an event that can affect all states) is triggered, it is necessary to perform a reset operation from the current state to the state corresponding to the global impact event. It can be seen that managing all states through a unified state machine will not only increase the complexity of the state and the state machine, but also greatly increase the management and maintenance costs of the state machine, and increase the possibility of loopholes in the state machine logic. In addition, once the definition of the state machine changes (for example, adding or reducing a state, etc.), it will lead to a large number of modifications to the state machine control program code, which also greatly increases the development difficulty and development cost of the application system based on the state machine.
[0042] Figure 1 Schematic diagram of the effect of the finite state machine of the Bluetooth phone in the prior art managing some states. Figure 1 As shown, take the Bluetooth phone management system as an example. Figure 1The rectangular boxes in the figure represent each state, and the lines represent the response relationship between states and specific state triggering events. Existing Bluetooth phone management systems use a large and comprehensive state machine to manage all states. The state changes presented by the final state machine are extremely complicated. For example, when the current state of a Bluetooth phone is synchronizing contacts, it cannot process the state of dialing contacts at the same time. For Bluetooth phones, the event of a Bluetooth disconnection is a global impact event. All states of a Bluetooth phone need to switch to a Bluetooth disconnected state and reset themselves or even the previous state when receiving a Bluetooth disconnection event. Figure 1 It can be seen that the complexity of the existing state machine is relatively high. Significantly, since each state may receive the "disconnect Bluetooth" event, it means that almost every state must handle this event. Figure 1 The state machine shown also requires a high degree of code redundancy, because a large number of states are detected due to the same event, such as "reject call", "call end" and other states are cut off due to the "countdown end" event; there are also a large number of states checked in by the same event, such as "Bluetooth not connected" state has "disconnect Bluetooth" checked in. However, these same operations are not handled uniformly, resulting in a large amount of code redundancy, which further increases the complexity of the state machine. Because the state machine is too complex and redundant, the flexibility of the state machine to adjust state management is poor, and the development and maintenance costs of the state machine are also increased.
[0043] In one example, Figure 2 is a flow chart of a state machine processing method provided by an embodiment of the present disclosure. This embodiment can be applied to the case of constructing a hierarchical finite state machine to efficiently manage states. The method can be executed by a state machine processing device, which can be implemented by software and / or hardware and can generally be integrated in an electronic device. Figure 2 As shown, the method includes the following operations:
[0044] S110. Determine a global state and a single state from all states of the state processing object.
[0045] Among them, the state processing object can be an object that uses a state machine to process various states of the system, and can be a specific electronic device, such as a terminal device with Bluetooth function, etc., or a virtual system object, such as a business process with multi-level state management attributes, etc. As long as the object has multiple state flows, it can be used as a state processing object. The embodiments of the present disclosure do not limit the specific types of state processing objects. The global state can be a state triggered by a global impact event. The global impact event can be an event that affects all states, such as a Bluetooth disconnection event in a Bluetooth device, etc. Correspondingly, the global state can be a Bluetooth unconnected state. The monomer state can be a state triggered by a non-global impact event. The non-global impact event can be an event that only affects a certain state, such as the call state of a Bluetooth phone, etc. The global state and the monomer state need to be determined according to the specific type of the state processing object. The embodiments of the present disclosure do not limit the specific state types of the global state and the monomer state.
[0046] In the disclosed embodiment, before constructing the state machine, the type and function of the state processing object can be analyzed first to determine two different state types, the global state and the single state, from all the states of the state processing object. Since the types of state triggering events corresponding to the global state and the single state are different, all states can be classified according to the state triggering event corresponding to each state to obtain the global state and the single state of the state processing object.
[0047] S120: Classify each of the monomer states to obtain at least one local state set.
[0048] The local state set may be a set including at least one monomer state.
[0049] Accordingly, after the classification of all states of the state processing object is completed, each monomer state of the state processing object can be further analyzed and classified according to the correlation between the monomer states, and each monomer state can be divided into a corresponding local state set. Optionally, when the state processing object is an electronic device, each local state set can include a monomer state corresponding to a certain function in the device. When the state processing object is a business process, each local state set can include a monomer state corresponding to a certain link in the business process.
[0050] For example, when the state processing object is a Bluetooth phone, the states related to outgoing calls, such as single states such as in-call, outgoing call, and cancel call, can be divided into a local state set, which can include all states related to outgoing calls. Similarly, all single states related to incoming calls can also be divided into a local state set. When the state processing object is a business process, the states related to the start node of the process, such as starting the device, initializing the configuration, and other single states can be divided into a local state set, which can include all states related to the start link of the process.
[0051] S130, constructing a sub-state machine for each of the local state sets; wherein each of the sub-state machines manages a single state in the local state set.
[0052] The sub-state machine may be a state machine that manages all monomer states in a local state set.
[0053] After obtaining the local state sets, corresponding sub-state machines can be constructed for each local state set. Optionally, each local state set can correspond to a sub-state machine. That is, each sub-state machine can focus on managing the monomer state in a certain local state set, but cannot manage the monomer state in other local state sets, nor can it manage the global state.
[0054] Exemplarily, when the state processing object is a Bluetooth phone, the local state set A of the Bluetooth phone may include all outgoing call related monomer states, and a sub-state machine A may be constructed for the local state set A. The sub-state machine A is used to manage all outgoing call related monomer states.
[0055] S140: construct a hierarchical finite state machine according to each of the sub-state machines and the global state.
[0056] The hierarchical finite state machine may be a state machine constructed by sub-state machines and a global state.
[0057] Correspondingly, after constructing the corresponding sub-state machines for each local state set of the state processing object, all global states and each sub-state machine can be combined to form a hierarchical finite state machine. That is, the hierarchical finite state machine can be composed of at least one sub-state machine and at least one global state. In the hierarchical finite state machine, the top-level state machine can be used to uniformly manage the states of all global states and sub-state machines. Optionally, the corresponding sub-state machine can be used to manage the single state.
[0058] It is understandable that after a state triggering event involving a non-global impact event, each state machine in the hierarchical finite state machine can be processed in a normal state processing manner. Exemplarily, taking a business process as a state processing object as an example, when a specific operation link sent by a subtask of a specific business is received, the monomer state corresponding to the subtask to be transferred can be obtained through the sub-state machine according to the specific operation link completed message. At the same time, it is also necessary to change the state of the sub-state machine according to the obtained monomer state corresponding to the subtask to be transferred. Taking a Bluetooth phone device as a state processing object as an example, after receiving a state triggering event of a non-global impact event, the target monomer state corresponding to the state triggering event is determined, and the state identification bit of the target monomer state is switched from the closed state to the open state, indicating that the target monomer state is the currently activated state. At the same time, the sub-state machine that manages the target monomer state can switch its own state identification bit from the closed state to the open state, indicating that the sub-state machine is currently in the activated state. Furthermore, if a state triggering event that globally affects an event is received, the top-level state machine can respond to the state triggering event based on the current global state, and determine the target sub-state machine for the state flow to activate the target sub-state machine, and the target sub-state machine will perform subsequent state processing procedures.
[0059] It should also be noted that, since the hierarchical finite state machine adopts a state processing method of classifying states and integrating them into sub-state machines, each sub-state machine can synchronously perform local processing of states, and at the same time, the hierarchical processing of states can also be synchronously performed between the global state and the monomer state. Exemplarily, taking a Bluetooth phone device as an example of a state processing object, the current state can be both the monomer state of the call in the electronic state machine and the monomer state of the synchronized address book in the address book synchronization sub-state machine, that is, the two monomer states of the call and the synchronized address book can be processed in parallel. Similarly, the current state can also be the global state of Bluetooth connected and the monomer state of the synchronized address book at the same time, that is, the global state of Bluetooth connected and the monomer state of the synchronized address book can be processed in parallel. It can be seen that the use of a hierarchical finite state machine to process states can avoid the logical limitations of state flow and improve the flexibility of state processing.
[0060] It can be seen that the hierarchical finite state machine breaks the centralized state management method of the unified state machine in the prior art by classifying the states and integrating them into sub-state machines, and decouples the state management function in a hierarchical manner, which can achieve distributed and targeted management of the states, thereby reducing the complexity and redundancy of the states and state machines, and reducing the development and maintenance costs of the state machines. Since the hierarchical finite state machine can use sub-state machines to manage the monomer states separately, the monomer state is not affected by other sub-state machines, that is, it is not affected by other unrelated monomer states, which improves the flexibility of the state machine in state control.
[0061] The disclosed embodiment determines the global state and the single state from all the states of the state processing object to classify each single state to obtain at least one local state set, and constructs a sub-state machine for each local state set that can manage the single state in the local state set, so as to construct a hierarchical finite state machine according to each sub-state machine and the global state, so as to utilize the hierarchical finite state machine to efficiently manage the state, and solve the problems existing in the existing state management method, such as the high complexity of the state machine and each state, the high cost of state machine development and maintenance, and the poor flexibility of state management, thereby reducing the complexity of the state machine and each state, reducing the development and maintenance cost of the state machine, and improving the flexibility of the state machine for state management.
[0062] In one example, Figure 3 It is a flow chart of a state machine processing method provided by an embodiment of the present disclosure. Based on the technical solutions of the above embodiments, the embodiment of the present disclosure has been optimized and improved, and a variety of specific optional implementation methods are provided for determining global states and monomer states, classifying each monomer state, constructing sub-state machines for each local state set, and constructing a hierarchical finite state machine.
[0063] like Figure 3 A state machine processing method shown includes:
[0064] S210: Determine the state response relationship and state triggering event of each state of the state processing object in sequence.
[0065] The state response relationship may be a response or switching relationship between various states, and the state triggering event may be an event that can affect the state switching.
[0066] In the embodiment of the present disclosure, before distinguishing the global state and the single state of the state processing object, the state response relationship and state triggering event of each state of the state processing object can be determined in sequence. It is understandable that there will be corresponding state response relationships between the global state and all other single states.
[0067] For example, Figure 1As shown, a Bluetooth phone device is used as an example to explain in detail: when the Bluetooth phone is currently in a single state during a call, if an event of disconnecting Bluetooth is received, it is necessary to switch from the single state during the call to the global state of Bluetooth not connected. Accordingly, there is a state response relationship between the single state during the call and the global state of Bluetooth not connected. Similarly, when it is currently in the single state during a call, if an event of hanging up the phone is received, it is necessary to switch from the single state during the call to the single state of call ending. Correspondingly, there is also a state response relationship between the single state during the call and the single state of call ending. It can be understood that each state has a corresponding state triggering event, such as the state triggering event during the call can be the other party answering the call, and the state triggering event of Bluetooth not connected is disconnecting Bluetooth, etc.
[0068] S220: When it is determined that the target state has a global state response relationship and / or there is an influence relationship between the target state and a target state triggering event, determine the target state as the global state.
[0069] The global state response relationship may be a state influence relationship between other states except itself. The target state trigger event may be a state trigger event type that can determine the global state, such as a global influence event.
[0070] Correspondingly, if it is determined that there is a state response relationship between a certain target state and all other states, that is, it is determined that the target state has a global state response relationship, and / or it is determined that there is an influence relationship between the target state and the target state triggering event, then the target state can be determined to be a global state.
[0071] For example, Figure 1 As shown, the two states of Bluetooth connected and Bluetooth disconnected have a state influence relationship with all other states directly or indirectly, that is, the state of Bluetooth connected has a global state influence relationship, and the state of Bluetooth connected can be determined as a global state. It can be understood that the event of disconnecting Bluetooth can be used as a target state trigger event, which has a global influence. Figure 1 As shown, there is an influence relationship between Bluetooth disconnection and each state. Therefore, the Bluetooth disconnection state can also be determined as a global state according to the influence relationship between the Bluetooth disconnection state and the Bluetooth disconnection state.
[0072] S230: Determine other states in the state processing object except the global state as the single state.
[0073] Correspondingly, after determining the global state, other states outside the global state can be determined as single states. Figure 1As shown, the two states of Bluetooth connected and Bluetooth not connected determine the global state, and the states of confirming dialing, outgoing call, and rejected call are all single states.
[0074] In the above scheme, the state type of the global state can be quickly determined according to the global state response relationship and the target state trigger event, thereby improving the efficiency of global state and monomer state classification.
[0075] S240: Determine a state mapping function of each of the monomer states.
[0076] Among them, the state mapping function can be a function corresponding to the implementation of the monomer state.
[0077] S250: Add the monomer states with the same state mapping function to each state set to obtain each local state set.
[0078] Specifically, each monomer state may be classified according to the state mapping function of each monomer state to obtain a corresponding local state set.
[0079] For example, Figure 1 As shown, for a Bluetooth phone, the state mapping functions corresponding to the states of confirming dialing, outgoing call, in-call, and call ended are all outgoing call functions. Therefore, the single states of confirming dialing, outgoing call, in-call, and call ended can be added to the state set to obtain a partial state set corresponding to the outgoing call function. Similarly, the state mapping functions corresponding to the states of ringing incoming call, in-call, rejecting incoming call, and call ended are all incoming call functions. Therefore, the single states of ringing incoming call, in-call, rejecting incoming call, and call ended can be added to the state set to obtain another partial state set corresponding to the incoming call function. Similarly, the state mapping functions corresponding to the states of synchronizing address book, address book empty, address book synchronization failed, and address book synchronization successfully are all address book synchronization functions. Therefore, the single states of synchronizing address book, address book empty, address book synchronization failed, and address book synchronization successfully can be added to the state set to obtain another partial state set corresponding to the address book synchronization function.
[0080] In the above technical solution, by dividing the local state set according to the state mapping function of each monomer state, the decoupling of the state management function can be achieved.
[0081] S260: Determine the sub-state machine identifier corresponding to each of the local state sets.
[0082] The sub-state machine identifier may be used to uniquely identify the sub-state machine.
[0083] S270: Establish a mapping relationship for each monomer state in each of the local state sets according to each of the sub-state machine identifiers.
[0084] Correspondingly, after obtaining each local state set, the sub-state machine identifier corresponding to each local state set can be determined according to the number of local state sets, and a mapping relationship can be established for the monomer state in each local state set according to each sub-state machine identifier to construct multiple sub-state machines.
[0085] To continue the explanation with the above example, a Bluetooth phone can include three local state sets: a local state set corresponding to the outgoing call function, a local state set corresponding to the incoming call function, and a local state set corresponding to the address book synchronization function. Therefore, three sub-state machine identifiers can be set for the Bluetooth phone: an outgoing call state machine, an incoming call state machine, and an address book synchronization sub-state machine. Furthermore, a mapping relationship between the outgoing call state machine identifier and the local state set corresponding to the outgoing call function can be established to obtain the outgoing call state machine, and a mapping relationship between the incoming call state machine identifier and the local state set corresponding to the incoming call function can be established to obtain the incoming call state machine, and a mapping relationship between the address book synchronization sub-state machine identifier and the local state set corresponding to the address book synchronization function can be established to obtain the address book synchronization sub-state machine.
[0086] S280: Determine a state response relationship and a state triggering event between each of the monomer states included in each of the sub-state machines.
[0087] In order to improve the management function of the sub-state machine, after establishing a mapping relationship between each local state set and each sub-state machine identifier, the state response relationship and state triggering event between each monomer state included in each sub-state machine can be further determined. At this point, the sub-state machine is constructed.
[0088] Exemplarily, the electronic state machine is used as an example to continue the explanation: a state response relationship is set between the single state of confirming dialing and the single state of outgoing call, and the state trigger event of switching from the single state of confirming dialing to the single state of outgoing call is set as the confirmed dialing event; a state response relationship is set between the single state of outgoing call and the single state of call, and the state trigger event of switching from the single state of outgoing call to the single state of call is set as the other party answering event; a state response relationship is set between the single state of call and the single state of call end, and the state trigger event of switching from the single state of call to the single state of call end is set as the phone hang up event.
[0089] The above technical solution improves the construction efficiency and quality of the sub-state machine by using the classified local state set to construct the sub-state machine, and can avoid the problem of logical loopholes.
[0090] S290: Determine the state response relationship and state triggering event of each of the global states.
[0091] S2A0. Construct the hierarchical finite state machine according to the state response relationship and state triggering event of each global state.
[0092] Considering that there is a corresponding state response relationship between the global state and all states, there is no need to configure a sub-state machine separately for the global state, and all global states can be uniformly managed by the top-level state machine. Among them, the top-level state machine can be a state machine with global management authority in the hierarchical finite state machine, so the states of each sub-state machine can also be managed. Optionally, the top-level state machine can determine the state response relationship and state triggering events between each global state and each sub-state machine to uniformly manage the global state and each sub-state machine. Accordingly, the top-level state machine, the global state, and each sub-state machine can constitute a complete hierarchical finite state machine.
[0093] Exemplarily, the above-mentioned Bluetooth phone is taken as an example to continue to explain: the above-mentioned example analysis shows that the global state of the Bluetooth phone can include Bluetooth connected and Bluetooth not connected. At the same time, according to the function of the Bluetooth phone, the state of being able to dial a contact can also be a global state. Therefore, the global state of the Bluetooth phone can include: Bluetooth connected, Bluetooth not connected, and being able to dial a contact. After determining the global state and each sub-state machine of the Bluetooth phone, the state response relationship and state triggering event of each global state can be determined respectively, and the hierarchical finite state machine can be further constructed according to the state response relationship and state triggering event of each global state. For example, there is a mutual state response relationship between Bluetooth connected and the electronic state machine. When the current state is the Bluetooth connected state, if the state triggering event of dialing the number occurs, the Bluetooth connected state can be switched to a certain monomer state in the electronic state machine (confirming dialing-outgoing call-calling, etc.), and when the call end in the electronic state machine is the current state and the countdown end event occurs, the call end state can be returned to switch to the Bluetooth connected state. Similarly, state response relationships and corresponding state triggering events may be determined between other global states, and state response relationships and corresponding state triggering events may be determined between each global state and each sub-state machine.
[0094] It should be noted that when constructing a hierarchical finite state machine based on the state response relationship and state triggering events of each global state, the processing method for different state triggering events can be determined for each sub-state machine. Exemplarily, for global impact events, the sub-state machine can set a batch processing mode. Taking a Bluetooth phone as an example, when a Bluetooth disconnection event occurs, if the previous state is the call state in the de-electronic state machine, the top-level state machine can instruct the de-electronic state machine to respond to the Bluetooth disconnection event. Correspondingly, the de-electronic state machine can uniformly perform state reset operations on all the single states it manages in batches, thereby simplifying the state processing method. At the same time, when the state machine needs to be developed or maintained, it is not necessary to modify all states. It is only necessary to locate the corresponding sub-state machine for local development or maintenance, thereby reducing the development and maintenance costs of the state machine.
[0095] In an optional embodiment of the present disclosure, the state machine processing method may also include: determining an updated monomer state; determining a state mapping function of the updated monomer state; determining an updated sub-state machine based on the state mapping function of the updated monomer state; and updating the state response relationship and state triggering event between each of the monomer states included in the updated sub-state machine.
[0096] The updating of the single state may be a single state that needs to be updated, and the updating of the sub-state machine may be a sub-state machine that needs to be updated. Optionally, the updating process may include but is not limited to adding, deleting or modifying.
[0097] In the embodiment of the present disclosure, when the state processing object updates the single-body state, such as when it is necessary to update the existing in-call state or to add a single-body state that does not currently exist, the state mapping function of the updated single-body state can be determined, that is, the associated function corresponding to the updated single-body state can be determined, and then the update sub-state machine can be determined according to the state mapping function of the updated single-body state, and the state response relationship and state trigger event between the single-body states included in the update sub-state machine can be updated.
[0098] Exemplarily, the above-mentioned Bluetooth phone is still used as an example to continue the description. If it is found that the event response state of canceling the call does not exist in the current Bluetooth phone, the canceling of the call can be determined as an updated single state. It can be understood that canceling the call belongs to the outgoing call function. Therefore, the updated single state of canceling the call can be added to the outgoing electronic state machine, and the outgoing electronic state machine can be determined as an updated sub-state machine to update the state response relationship and state triggering events between all single states included in the outgoing electronic state machine. Similarly, if there is a global state that needs to be updated, the updated global state can be added to the top-level state machine, and the state response relationship and state triggering events between all states included in the top-level state machine can be updated.
[0099] In the above technical solution, by updating the sub-state machines, the control function of each sub-state machine can be continuously improved according to actual needs, thereby improving the state control capability of the hierarchical finite state machine.
[0100] Figure 4 is a schematic diagram of a hierarchical finite state machine of a Bluetooth phone device provided by an embodiment of the present disclosure. In an optional embodiment of the present disclosure, Figure 4 As shown, the state processing object may include a Bluetooth phone device, such as a car-mounted Bluetooth phone device in the Internet of Vehicles technology; the global state may include Bluetooth connected, Bluetooth disconnected, and able to call contacts; the sub-state machine may include an outgoing call state machine, an incoming call state machine, and an address book synchronization sub-state machine.
[0101] like Figure 4 As shown, the outgoing state machine can manage all the single states related to the outgoing function of the Bluetooth phone device, the incoming state machine can manage all the single states related to the incoming function of the Bluetooth phone device, and the address book synchronization sub-state machine can manage all the single states related to the address book synchronization function of the Bluetooth phone device. Each sub-state machine can establish a corresponding connection relationship with the global state according to the specific state trigger event, thereby forming a hierarchical finite state machine together with each global state.
[0102] The advantage of this setting is that by adding sub-state machines to classify the states, the number of states in the same sub-state machine can be reduced, and the state changes between different sub-state machines can be standardized. For example, when the single state is currently in the confirming dialing state in the de-electronic state machine, if the Bluetooth connection disconnection event is triggered, it is not necessary to notify the single state in the confirming dialing state in the de-electronic state machine to perform a reset operation. The de-electronic state machine can immediately perform a batch reset process on all single states in the outer layer, thereby reducing the complexity of state management. At the same time, all states in the sub-state machine are uniformly processed for routine events (such as "disconnecting Bluetooth") that need to be handled, and the logic of a large number of repeated operations is unified, which can not only reduce the amount of redundant code in the state machine, but also further reduce the complexity of all states in the sub-state machine.
[0103] The above technical scheme classifies states by utilizing the state response relationship and state triggering events of states to determine the global state and the monomer state, so as to classify each monomer state to obtain at least one local state set, and construct a sub-state machine for each local state set that can manage the monomer state in the local state set, so as to construct a hierarchical finite state machine according to each sub-state machine and the global state, so as to utilize the hierarchical finite state machine to efficiently manage the state, and solve the problems existing in the existing state management method, such as the high complexity of the state machine and each state, the high cost of state machine development and maintenance, and the poor flexibility of state control, thereby reducing the complexity of the state machine and each state, reducing the development and maintenance cost of the state machine, and improving the flexibility of the state machine for state control.
[0104] In one example, Figure 5 is a flow chart of a state processing method provided by an embodiment of the present disclosure. This embodiment is applicable to the case of efficiently managing states using a hierarchical finite state machine. The method can be executed by a state processing device, which can be implemented by software and / or hardware and can generally be integrated in an electronic device. Figure 5 As shown, the method includes the following operations:
[0105] S310: Determine a state triggering event of a state processing object.
[0106] It is understandable that the state processing object needs to receive a state triggering event before it triggers the switching process of the internal state. Therefore, when the state processing object uses a hierarchical finite state machine to process the state, it needs to first determine the state triggering event.
[0107] S320: respond to the state triggering event according to the state triggering event and the hierarchical finite state machine of the state processing object.
[0108] Wherein, the hierarchical finite state machine is constructed by the state machine processing method described in any of the above embodiments.
[0109] S330: Determine the current update status according to the response result of the status triggering event.
[0110] Among them, the current update state can be an updated state determined by the hierarchical finite state machine according to the response result of the state triggering event, and can be a global state or a single state, which is not limited in the embodiments of the present disclosure.
[0111] Correspondingly, after determining the state triggering event, the hierarchical finite state machine of the state processing object can be used to respond to the state triggering event according to the type of the state triggering event, thereby determining the current update state according to the response result.
[0112] Exemplarily, taking a business process as a state processing object as an example, when a specific operation link sent by a subtask of a specific business is received, the monomer state corresponding to the subtask to be transferred can be obtained through the sub-state machine according to the specific operation link completed message. At the same time, it is also necessary to change the state of the sub-state machine according to the monomer state corresponding to the subtask to be transferred. Taking a Bluetooth phone device as a state processing object as an example, when a state triggering event of a non-global impact event is received and it is determined that the state triggering event response is successful, the target monomer state corresponding to the state triggering event is determined, and the state identification bit of the target monomer state is switched from the closed state to the open state, indicating that the target monomer state is the currently activated state. At the same time, the sub-state machine that manages the target monomer state can switch its own state identification bit from the closed state to the open state, indicating that the sub-state machine is currently in the activated state. Further, if a state triggering event of a global impact event is received, the top-level state machine can respond to the state triggering event based on the current global state, and determine the target sub-state machine of the state transfer to activate the target sub-state machine, and the target sub-state machine performs the subsequent state processing flow.
[0113] The disclosed embodiment determines the global state and the monomer state from all the states of the state processing object, classifies each monomer state to obtain at least one local state set, and constructs a sub-state machine that can manage the monomer state in the local state set for each local state set, thereby constructing a hierarchical finite state machine according to each sub-state machine and the global state. After the hierarchical finite state machine is constructed, when the state triggering event of the state processing object is determined, the state triggering event can be responded to according to the state triggering event and the hierarchical finite state machine of the state processing object, and the current update state is determined according to the response result of the state triggering event, so as to solve the problems existing in the existing state management method, such as the high complexity of the state machine and each state, the high cost of state machine development and maintenance, and the poor flexibility of state control, thereby reducing the complexity of the state machine and each state, reducing the development and maintenance cost of the state machine, and improving the flexibility of the state machine for state control.
[0114] In one example, Figure 6 It is a flowchart of a state machine processing method provided by an embodiment of the present disclosure. Based on the technical solutions of the above-mentioned embodiments, the embodiment of the present disclosure has been optimized and improved, and a specific optional implementation method for responding to the state triggering event according to the hierarchical finite state machine of the state processing object is given.
[0115] like Figure 6 A state processing method shown includes:
[0116] S410: Determine a state triggering event of a state processing object.
[0117] The state triggering event includes a target global impact event. The target global impact event may be a global impact event that can instruct the sub-state machine to perform a batch update on the monomer states included in it.
[0118] S420: Determine the currently activated sub-state machine.
[0119] The currently activated sub-state machine may be a sub-state machine that is currently in an activated state.
[0120] S430: Instruct the currently activated sub-state machine to update its state according to the state response relationship between the target global impact event and the currently activated sub-state machine.
[0121] Since the target global impact event can instruct the sub-state machine to perform batch updates on the monomer states it includes, after determining that the type of the state triggering event is the target global impact event, the state response relationship between the target global impact event and the currently activated sub-state machine can be determined, and the currently activated sub-state machine can be instructed to perform state updates according to the state response relationship. Optionally, the top-level state machine in the hierarchical finite state machine can instruct the currently activated sub-state machine to perform state updates according to the state response relationship.
[0122] S440: Batch update each monomer state included in the currently activated sub-state machine through the currently activated sub-state machine.
[0123] Correspondingly, after receiving the indication message of the state update, the currently activated sub-state machine can batch update all the monomer states included therein.
[0124] Take a Bluetooth phone as an example. When the target global impact event is a Bluetooth disconnection event, if the currently activated sub-state machine is a de-electronic state machine, and the currently activated single state in the de-electronic state machine is a call-in state, the top-level state machine can instruct the de-electronic state machine to respond to the Bluetooth disconnection event. Accordingly, the de-electronic state machine can perform a batch reset operation on all single states it manages, such as batch controlling the state flags of all single states to switch to the off state, thereby simplifying the state processing method and improving the state processing efficiency and accuracy.
[0125] S450: Determine the current update state of the hierarchical finite state machine.
[0126] The above technical solution responds to the target global impact event by using the hierarchical finite state machine of the target global impact event and the state processing object, and can realize batch update of the monomer state through the sub-state machine, thereby simplifying the state processing method and improving the state processing efficiency and accuracy.
[0127] It should be noted that any arrangement and combination of the technical features in the above embodiments also falls within the protection scope of the present disclosure.
[0128] In one example, Figure 7 It is a structural diagram of a state machine processing device provided by an embodiment of the present disclosure. The embodiment of the present disclosure can be applied to the situation of constructing a hierarchical finite state machine to efficiently manage states. The device is implemented by software and / or hardware and is specifically configured in an electronic device.
[0129] like Figure 7 The state machine processing device 500 shown in the figure comprises: a state determination module 510, a single state classification module 520, a sub-state machine construction module 530 and a hierarchical finite state machine construction module 540.
[0130] A state determination module 510, for determining a global state and a single state from all states of the state processing object;
[0131] A monomer state classification module 520, used to classify each of the monomer states to obtain at least one local state set;
[0132] A sub-state machine construction module 530 is used to construct a sub-state machine for each of the local state sets; wherein each of the sub-state machines manages a single state in the local state set;
[0133] The hierarchical finite state machine construction module 540 is used to construct a hierarchical finite state machine according to each of the sub-state machines and the global state.
[0134] The disclosed embodiment determines the global state and the single state from all the states of the state processing object to classify each single state to obtain at least one local state set, and constructs a sub-state machine for each local state set that can manage the single state in the local state set, so as to construct a hierarchical finite state machine according to each sub-state machine and the global state, so as to utilize the hierarchical finite state machine to efficiently manage the state, and solve the problems existing in the existing state management method, such as the high complexity of the state machine and each state, the high cost of state machine development and maintenance, and the poor flexibility of state management, thereby reducing the complexity of the state machine and each state, reducing the development and maintenance cost of the state machine, and improving the flexibility of the state machine for state management.
[0135] Optionally, the state determination module 510 is specifically used to: determine the state response relationship and state trigger event of each state of the state processing object in sequence; when it is determined that the target state has a global state response relationship and / or there is an influence relationship between the target state and the target state trigger event, determine the target state as the global state; determine other states in the state processing object except the global state as the monomer state.
[0136] Optionally, the monomer state classification module 520 is specifically used to: determine the state mapping function of each of the monomer states; and add the monomer states with the same state mapping function to each state set to obtain each of the local state sets.
[0137] Optionally, the sub-state machine construction module 530 is specifically used to: determine the sub-state machine identifier corresponding to each of the local state sets; establish a mapping relationship for the monomer states in each of the local state sets based on each of the sub-state machine identifiers; and determine the state response relationship and state triggering events between each of the monomer states included in each of the sub-state machines.
[0138] Optionally, the hierarchical finite state machine construction module 540 is specifically used to: determine the state response relationship and state triggering event of each of the global states; and construct the hierarchical finite state machine according to the state response relationship and state triggering event of each of the global states.
[0139] Optionally, the state machine processing device also includes: an update monomer state determination module, used to determine the update monomer state; a state mapping function determination module, used to determine the state mapping function of the update monomer state; an update sub-state machine determination module, used to determine the update sub-state machine according to the state mapping function of the update monomer state; a relationship event update module, used to update the state response relationship and state triggering events between each of the monomer states included in the update sub-state machine.
[0140] Optionally, the state processing object includes a Bluetooth phone device; the global state includes Bluetooth connected, Bluetooth disconnected and able to call contacts; the sub-state machine includes an outgoing call state machine, an incoming call state machine and an address book synchronization sub-state machine.
[0141] The above-mentioned state machine processing device can execute the state machine processing method provided by any embodiment of the present disclosure, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in this embodiment, please refer to the state machine processing method provided by any embodiment of the present disclosure.
[0142] Since the state machine processing device introduced above is a device that can execute the state machine processing method in the embodiment of the present disclosure, based on the state machine processing method introduced in the embodiment of the present disclosure, the technical personnel in this field can understand the specific implementation of the state machine processing device of this embodiment and its various variations, so how the state machine processing device implements the state machine processing method in the embodiment of the present disclosure is not described in detail here. As long as the technical personnel in this field implement the device used by the state machine processing method in the embodiment of the present disclosure, it belongs to the scope of protection of the present disclosure.
[0143] In one example, Figure 8 It is a structural diagram of a state machine processing device provided by an embodiment of the present disclosure. The embodiment of the present disclosure can be applied to situations where a hierarchical finite state machine is used to efficiently manage states. The device is implemented through software and / or hardware and is specifically configured in an electronic device.
[0144] like Figure 8 The state processing device 600 shown in the figure includes: a state triggering event determining module 610, a state triggering event responding module 620 and a current update state determining module 630.
[0145] A state triggering event determining module 610, used to determine a state triggering event of a state processing object;
[0146] A state triggering event response module 620, configured to respond to the state triggering event according to the state triggering event and the hierarchical finite state machine of the state processing object; wherein the hierarchical finite state machine is constructed by the state machine processing method described in any of the above embodiments;
[0147] The current update state determination module 630 is used to determine the current update state according to the response result of the state triggering event.
[0148] The disclosed embodiment determines the global state and the monomer state from all the states of the state processing object, classifies each monomer state to obtain at least one local state set, and constructs a sub-state machine that can manage the monomer state in the local state set for each local state set, thereby constructing a hierarchical finite state machine according to each sub-state machine and the global state. After the hierarchical finite state machine is constructed, when the state triggering event of the state processing object is determined, the state triggering event can be responded to according to the state triggering event and the hierarchical finite state machine of the state processing object, and the current update state is determined according to the response result of the state triggering event, so as to solve the problems existing in the existing state management method, such as the high complexity of the state machine and each state, the high cost of state machine development and maintenance, and the poor flexibility of state control, thereby reducing the complexity of the state machine and each state, reducing the development and maintenance cost of the state machine, and improving the flexibility of the state machine for state control.
[0149] Optionally, the state triggering event includes a target global impact event; the state triggering event response module 620 is specifically used to: determine the currently activated sub-state machine; instruct the currently activated sub-state machine to perform a state update based on the state response relationship between the target global impact event and the currently activated sub-state machine; and batch update each individual state included in the currently activated sub-state machine through the currently activated sub-state machine.
[0150] The above-mentioned state processing device can execute the state processing method provided by any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method. For technical details not fully described in this embodiment, please refer to the state processing method provided by any embodiment of the present disclosure.
[0151] Since the state processing device introduced above is a device that can execute the state processing method in the embodiment of the present disclosure, based on the state processing method introduced in the embodiment of the present disclosure, the technical personnel in the field can understand the specific implementation of the state processing device of the present embodiment and its various variations, so how the state processing device implements the state processing method in the embodiment of the present disclosure is not described in detail here. As long as the technical personnel in the field implement the device used in the state processing method in the embodiment of the present disclosure, it belongs to the scope of protection of the present disclosure.
[0152] In one example, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0153] Fig. 9 A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0154] like Fig. 9As shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0155] A number of components in the device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0156] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as a state machine processing method or a state processing method. For example, in some embodiments, the state machine processing method or the state processing method may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the state machine processing method or the state processing method described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to execute the state machine processing method or the state processing method in any other appropriate manner (eg, by means of firmware).
[0157] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0158] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0159] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0160] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0161] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0162] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0163] The disclosed embodiment determines the global state and the monomer state from all the states of the state processing object, classifies each monomer state to obtain at least one local state set, and constructs a sub-state machine that can manage the monomer state in the local state set for each local state set, thereby constructing a hierarchical finite state machine according to each sub-state machine and the global state. After the hierarchical finite state machine is constructed, when the state triggering event of the state processing object is determined, the state triggering event can be responded to according to the state triggering event and the hierarchical finite state machine of the state processing object, and the current update state is determined according to the response result of the state triggering event, so as to solve the problems existing in the existing state management method, such as the high complexity of the state machine and each state, the high cost of state machine development and maintenance, and the poor flexibility of state control, thereby reducing the complexity of the state machine and each state, reducing the development and maintenance cost of the state machine, and improving the flexibility of the state machine for state control.
[0164] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0165] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A state machine processing method, comprising: Determine the global state and the individual state from all the states of the state processing object; Classifying each of the monomer states to obtain at least one local state set; Constructing a sub-state machine for each of the local state sets; wherein each of the sub-state machines manages a single state in the local state set; Constructing a hierarchical finite state machine according to each of the sub-state machines and the global state; Wherein, constructing a sub-state machine for each of the local state sets includes: Determine the sub-state machine identifier corresponding to each of the local state sets; Establishing a mapping relationship between the monomer states in each of the local state sets according to each of the sub-state machine identifiers; The state response relationship and state triggering event between each of the monomer states included in each of the sub-state machines are determined.
2. The method according to claim 1, wherein: The determining of the global state and the single state from all states of the state processing object includes: Determine the state response relationship and state triggering event of each state of the state processing object in sequence; In the case where it is determined that the target state has a global state response relationship and / or there is an influence relationship between the target state and a target state triggering event, determining the target state as the global state; The other states in the state processing object except the global state are determined as the singleton states.
3. The method according to claim 1, wherein: Classify each of the monomer states to obtain at least one local state set, including: Determine a state mapping function for each of the monomer states; The monomer states with the same state mapping function are added to each state set to obtain each local state set.
4. The method according to claim 1, wherein: The step of constructing a hierarchical finite state machine according to each of the sub-state machines and the global state includes: Determine the state response relationship and state triggering event of each of the global states; The hierarchical finite state machine is constructed according to the state response relationship and state triggering events of each of the global states.
5. The method according to any one of claims 1 to 4, further comprising: Determine the update state of the monomer; Determine a state mapping function for updating the monomer state; Determine an update sub-state machine according to the state mapping function of updating the monomer state; The state response relationship and state triggering event between the monomer states included in the update sub-state machine are updated.
6. The method according to any one of claims 1 to 4, wherein: The state processing object includes a Bluetooth phone device; The global status includes Bluetooth connected, Bluetooth disconnected, and available to call contacts; The sub-state machines include an outgoing call state machine, an incoming call state machine and an address book synchronization sub-state machine.
7. A state processing method, comprising: Determine the state triggering event of the state processing object; A hierarchical finite state machine responds to the state triggering event according to the state triggering event and the state processing object; wherein the hierarchical finite state machine is constructed by the state machine processing method according to any one of claims 1 to 6; The current update state is determined according to the response result of the state triggering event.
8. The method according to claim 7, wherein: The state triggering event includes a target global impact event; The hierarchical finite state machine according to the state triggering event and the state processing object responds to the state triggering event, including: Determine the currently activated sub-state machine; Instructing the currently activated sub-state machine to update its state according to a state response relationship between the target global impact event and the currently activated sub-state machine; The individual states included in the currently activated sub-state machine are updated in batches through the currently activated sub-state machine.
9. A state machine processing device, comprising: A state determination module, used for determining a global state and a single state from all states of a state processing object; A monomer state classification module, used for classifying each of the monomer states to obtain at least one local state set; A sub-state machine construction module, used to construct a sub-state machine for each of the local state sets; wherein each of the sub-state machines manages a single state in the local state set; A hierarchical finite state machine construction module, used for constructing a hierarchical finite state machine according to each of the sub-state machines and the global state; Wherein, the sub-state machine construction module is specifically used for: Determine the sub-state machine identifier corresponding to each of the local state sets; Establishing a mapping relationship between the monomer states in each of the local state sets according to each of the sub-state machine identifiers; The state response relationship and state triggering event between each of the monomer states included in each of the sub-state machines are determined.
10. The device according to claim 9, wherein: The state determination module is specifically used for: Determine the state response relationship and state triggering event of each state of the state processing object in sequence; In the case where it is determined that the target state has a global state response relationship and / or there is an influence relationship between the target state and a target state triggering event, determining the target state as the global state; The other states in the state processing object except the global state are determined as the singleton states.
11. The device according to claim 9, wherein: The monomer state classification module is specifically used for: Determine a state mapping function for each of the monomer states; The monomer states with the same state mapping function are added to each state set to obtain each local state set.
12. The device according to claim 9, wherein: The hierarchical finite state machine building module is specifically used for: Determine the state response relationship and state triggering event of each of the global states; The hierarchical finite state machine is constructed according to the state response relationship and state triggering events of each of the global states.
13. The device according to any one of claims 9 to 12, further comprising: An update monomer state determination module is used to determine the update monomer state; A state mapping function determination module, used to determine the state mapping function of the update monomer state; An update sub-state machine determination module, used to determine the update sub-state machine according to the state mapping function of the update monomer state; The relationship event updating module is used to update the state response relationship and state triggering event between each of the monomer states included in the update sub-state machine.
14. The device according to any one of claims 9 to 12, wherein: The state processing object includes a Bluetooth phone device; The global status includes Bluetooth connected, Bluetooth disconnected, and available to call contacts; The sub-state machines include an outgoing call state machine, an incoming call state machine and an address book synchronization sub-state machine.
15. A state processing device, comprising: A state triggering event determination module, used to determine the state triggering event of the state processing object; A state triggering event response module, used to respond to the state triggering event according to the state triggering event and the hierarchical finite state machine of the state processing object; wherein the hierarchical finite state machine is constructed by the state machine processing method according to any one of claims 1 to 6; The current update state determination module is used to determine the current update state according to the response result of the state triggering event.
16. The device according to claim 15, wherein: The state triggering event includes a target global impact event; The state triggering event response module is specifically used for: Determine the currently activated sub-state machine; Instructing the currently activated sub-state machine to update its state according to a state response relationship between the target global impact event and the currently activated sub-state machine; The individual states included in the currently activated sub-state machine are updated in batches through the currently activated sub-state machine.
17. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the state machine processing method described in any one of claims 1-6, or execute the state processing method described in any one of claims 7-8.
18. A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the state machine processing method according to any one of claims 1 to 6, or to execute the state processing method according to any one of claims 7 to 8.
19. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the state machine processing method according to any one of claims 1 to 6, or executes the state processing method according to any one of claims 7 to 8.
