CN1519706A - Method for implementing a flow state machine - Google Patents

Method for implementing a flow state machine Download PDF

Info

Publication number
CN1519706A
CN1519706A CNA031152023A CN03115202A CN1519706A CN 1519706 A CN1519706 A CN 1519706A CN A031152023 A CNA031152023 A CN A031152023A CN 03115202 A CN03115202 A CN 03115202A CN 1519706 A CN1519706 A CN 1519706A
Authority
CN
China
Prior art keywords
state
stack
message
flow
sub
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CNA031152023A
Other languages
Chinese (zh)
Other versions
CN1323351C (en
Inventor
磊 郭
郭磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ZTE Corp
Original Assignee
ZTE Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by ZTE Corp filed Critical ZTE Corp
Priority to CNB031152023A priority Critical patent/CN1323351C/en
Publication of CN1519706A publication Critical patent/CN1519706A/en
Application granted granted Critical
Publication of CN1323351C publication Critical patent/CN1323351C/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Abstract

The method uses model of state stack includes normal message handling flow, abnormal message handling flow and abnormal state handling flow, which utilize general state stack. Implementing method of flow state machine raises handling efficiency, simplifies handling flow, and is as a general implementation method applicable to processes of diversified state machines.

Description

A kind of implementation method of flow state machine
Technical field
The present invention relates to finite state machine, specifically, relate to a kind of software implementation method of flow state machine, more particularly, relate to the common software implementation method of operation flow state machine in the communications protocol exploitation.
Background technology
Finite state machine Finite State Machine is called for short FSM, is research object in the automaton theory, can realize with software or hardware.In software module exploitation as communication protocol flow, relate to the variation of operation flow state in a large number, to describe the realization of operation flow, be very suitable for adopting FSM structure and flow state machine.In the specific implementation of communication protocol flow and operation flow state machine, need continuous transition state, the process of moving into and move out, the message of wait and treatment progress.For communication protocol flow, state processing and conversion run through flow processing all the time, more for a long time, processing is that more complicated is loaded down with trivial details at flow state, processing and implementation method that quality that whole flow state is handled and efficient are decided by the selected operation flow state machine of flow state developer.At present, the developer handles for various flow state machines and realizes all is that situation according to idiographic flow adopts different concrete grammars, and for the processing and the realization of the flow state machine that contains complicated communication traffic flow process in the communication system, this mode is not owing to relate to a total thinking and mode, realize complicated flow state machine will be loaded down with trivial details, efficient is not high and unintelligible, guarantee thereby cause quality that the flow state of whole communication system handles and efficient to can not get essence.
Summary of the invention
The technical problem to be solved in the present invention is, how to adopt stack and stack operation, constructs a kind of general implementation method of flow state machine, can realize complicated flow state machine clear and efficiently, with quality and the efficient that ensures that flow state is handled.
The above-mentioned technical matters of the present invention solves like this, constructs a kind of implementation method of flow state machine, it is characterized in that, adopts the state stack model, comprises the general implementation method of flow state machine in normal process flow process, unexpected message processing and the abnormality processing.
Implementation method according to flow state machine provided by the invention is characterized in that, described state stack model is multistage flow state stack, comprises major state and sub-state at different levels.
Implementation method according to flow state machine provided by the invention is characterized in that, described multistage flow state stack is the two-stage process state stack, comprises a major state and a plurality of sub-state.
Implementation method according to flow state machine provided by the invention is characterized in that, the normal messages treatment scheme of described generic state stack may further comprise the steps:
4.1) the state stack initialization;
4.2) state stack waits for the arrival of news, the message that the state stack acquisition is distributed, take out the current state of state stack, if current state is arranged, change the Message Processing of corresponding states over to, if there is not current state, major state is gone into state stack, change the Message Processing of major state over to, described current state is sub-state or major state;
4.3) after described Message Processing is intact, return the state that calls this Message Processing; If return sub-state, next sub-state or major state that judgement will be moved are provided with do well stack and described next sub-state or major state of current sub-state and go into state stack, move out of this process, return step (4.2); If the major state of returning judges whether flow process finishes, if flow process does not finish, the sub-state that judgement will be moved is provided with do well stack and described sub-state of major state and goes into state stack and move out of this process, returns step (4.2); Otherwise the removing state stack finishes the normal process flow process.
Implementation method according to flow state machine provided by the invention is characterized in that, the unexpected message treatment scheme of described generic state stack may further comprise the steps:
5.1) judge whether unexpected message will cause interference and conflict to current flow process, interfere and conflict if do not cause, and the unexpected message treatment scheme of described state stack can abandon this unexpected message;
5.2) if cause interference and conflict, according to the conflict type or the conflict priority of this unexpected message, content in the state stack is carried out part reset or reset all.
In implementation method according to flow state machine provided by the invention, it is characterized in that, before the step of the current sub-state of the described taking-up state stack of step (4.3), add the step that message is judged, judge that promptly message is normal messages or unexpected message, it is normal messages, continue step (4.2), otherwise change the unexpected message treatment scheme over to, be i.e. step (5.1).
In implementation method according to flow state machine provided by the invention, it is characterized in that, in the abnormality treatment scheme of described generic state stack, described state stack is provided with the maintenance timer of particular state, when state stack enters described particular state, begins to start the maintenance timer, timing scan, in case described particular state is overtime, remove state stack, the end process flow process.
The general implementation method of a kind of flow state machine provided by the invention has improved the treatment effeciency of communication system operation flow state, has simplified treatment scheme, and can be used as the processing that a kind of general implementation method is applied to various state machines.
Description of drawings
Fig. 1 is the synoptic diagram of two-stage process state stack structure provided by the invention and state transition.
Fig. 2 is the synoptic diagram of generic state stack normal messages treatment scheme provided by the invention.
Embodiment
In conjunction with the accompanying drawings and embodiments, the inventive method is further launched.At first, illustrate that the basic point of inventive method is as follows:
The present invention utilizes the operation of stack that state transition and conversion are handled, and the operation of stack has reflected the variation of state, promotes the development of flow process, treatment scheme simple and clear by the operation of stack; From OO viewpoint, state has concussion, recall and the behavior property of behavioral characteristic repeatedly and state stack meets fully, and this method can realize with the pattern of Object-Oriented Design, the state stack model is suitable for the realization of general flow state machine simultaneously, and very strong versatility is arranged.
Flow state generally can be divided into multistage in the state stack model.When realizing with the flow state stack, can generally only divide two-stage is major state and sub-state (state except that major state), and the structure of two-stage process state stack as shown in Figure 1.After operation flow entered major state, it all was that conditionality is carried out that a lot of sub-states are arranged, may be not in order, even may be inverted order and recall execution, but after each current state finishes dealing with, all to get back to the state that calls it, judge the trend of flow process, the next state that selection will enter.In current state, make one's options and judge the next state that to move to, carry out state transition.Wait for next message, carry out Message Processing and state transformation, arrive major state, and major state is finished dealing with removing state stack, end process flow process up to sub-state transition.
The implementation method of the generalized flowsheet state machine that proposes according to the present invention is described as follows one by one to each step: (state stack is realized with object-oriented way)
(1) normal process realization flow, its process be as shown in Figure 2:
1, with the startup of various concrete business realizing corresponding service treatment progress, resources allocation, state stack initialization: when beginning to carry out operation flow, flow process to each client of prepare handling is all distributed a state stack data field, and its data data field content is determined according to concrete protocol description and flow processing needs.The number of described state stack data field and content also can be self-defined.
(produce message, business process scheduling and switching enter the Message Processing flow process, by protocol handler each state stack dispatch messages to its distribution)
2, state stack is waited for its message, and state stack obtains the message that is distributed to it and prepares to handle, and judges News Category, if normal messages, handle by following normal flow, take out the current state of state stack: (if unexpected message abandons or the processing that conflicts)
1. be empty as current state, show it is the first message of this state stack, change state stack data field data, major state is stacked, and the method that changes the major state Message Processing over to is handled described message;
2. otherwise, change the method that corresponding status message handles over to and handle described message.This state can be a major state, also can be sub-state.
3, after described Message Processing is finished, return the state that calls this Message Processing; If sub-state, the state that judgement will be moved, change state stack data field data, it is stacked that the state that previous status pops, will move is set, and move out of this process, returns step 2; If major state judges whether flow process finishes, if handle intactly, then judge the state that will move, change state stack data field data, it is stacked that the state that previous status pops, will move is set, and move out of this process, returns step 2; Otherwise the removing state stack, releasing allocated resources withdraws from the Message Processing flow process.
(2) processing of unexpected message:
(in the service condition machine is handled, must consider the abnormal conditions in the flow process more fully.The present embodiment abnormality processing divides two parts to realize, is respectively that the processing (two) and the abnormality of unexpected message handled (three).)
When receiving message and the extraction state is prepared to handle from stack, this message may not be desired message of this flow state or the message that can cause conflict.If this message does not need to handle, then it can be abandoned, wait for the state transition that next message is handled and cause thus; Interfere and conflict if this message will cause current flow process, must handle.At this moment, can content in the state stack be reset, new major state or sub-state are set, comprise all and resetting with part according to conflict type or conflict priority.Reset all is cancelled original flow process and state exactly, resets major state, changes new operation flow over to; And the part replacement is exactly that new sub-state is set.(for the multi-level state stack, it is exactly to reset certain one deck or relevant several layer states that part is reset, and does not change major state, realizes only changing the purpose of partial service sub-process)
(3) processing of abnormal state: in the long transition of flow state, may can't move, cause resource from suspending because certain abnormal conditions cause long-time suspension of state of state stack.Can carry out timing scan at corresponding state during processing, flow process enters the maintenance timer that this state just is provided with this state, and it is unusual that timer expiry can think that state takes place, and the site clearing discharges resource then, and process ends is handled.

Claims (8)

1, a kind of implementation method of flow state machine is characterized in that, adopts the state stack model, comprises the normal messages treatment scheme of generic state stack, the unexpected message treatment scheme of generic state stack and the abnormality treatment scheme of generic state stack.
According to the implementation method of the described flow state machine of claim 1, it is characterized in that 2, described state stack model is the multi-level state stack, comprise major state and sub-state at different levels.
According to the implementation method of the described flow state machine of claim 1, it is characterized in that 3, described multi-level state stack is the two-stage process state stack, comprise a major state and a plurality of sub-state.
According to the implementation method of any one described flow state machine among the claim 1-3, it is characterized in that 4, the normal messages treatment scheme of described generic state stack may further comprise the steps:
4.1) the state stack initialization;
4.2) state stack waits for the arrival of news, the message that the state stack acquisition is distributed, take out the current state of state stack, if current state is arranged, change the Message Processing of corresponding states over to, if there is not current state, major state is gone into state stack, change the Message Processing of major state over to, described current state is sub-state or major state;
4.3) after described Message Processing is intact, return the state that calls this Message Processing; If return sub-state, next sub-state or major state that judgement will be moved are provided with do well stack and described next sub-state or major state of current sub-state and go into state stack, move out of this process, return step (4.2); If the major state of returning judges whether flow process finishes, if flow process does not finish, the sub-state that judgement will be moved is provided with do well stack and described sub-state of major state and goes into state stack and move out of this process, returns step (4.2); Otherwise the removing state stack finishes the normal process flow process.
According to the implementation method of the described flow state machine of claim 4, it is characterized in that 5, the unexpected message treatment scheme of described generic state stack may further comprise the steps:
5.1) judge whether unexpected message will cause interference and conflict to current flow process, interfere and conflict if do not cause, and the unexpected message treatment scheme of described state stack can abandon this unexpected message;
5.2) if cause interference and conflict, according to the conflict type or the conflict priority of this unexpected message, content in the state stack is carried out part reset or reset all.
6, according to the implementation method of the described flow state machine of claim 4, it is characterized in that, before the step of the current sub-state of the described taking-up state stack of step (4.3), add the step that message is judged, judge that promptly message is normal messages or unexpected message, it is normal messages, continue step (4.3), otherwise change the unexpected message treatment scheme over to, be i.e. step (5.1).
7, according to the implementation method of the described flow state machine of claim 5, it is characterized in that, before the step of the current sub-state of the described taking-up state stack of step (4.3), add the step that message is judged, judge that promptly message is normal messages or unexpected message, it is normal messages, continue step (4.3), otherwise change the unexpected message treatment scheme over to, be i.e. step (5.1).
8, according to the implementation method of the described flow state machine of claim 5, it is characterized in that, in the abnormality treatment scheme of described generic state stack, described state stack is provided with the maintenance timer of particular state, when state stack enters described particular state, begins to start described maintenance timer, timing scan, in case described particular state is overtime, remove state stack, the end process flow process.
CNB031152023A 2003-01-23 2003-01-23 Method for implementing a flow state machine Expired - Fee Related CN1323351C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB031152023A CN1323351C (en) 2003-01-23 2003-01-23 Method for implementing a flow state machine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB031152023A CN1323351C (en) 2003-01-23 2003-01-23 Method for implementing a flow state machine

Publications (2)

Publication Number Publication Date
CN1519706A true CN1519706A (en) 2004-08-11
CN1323351C CN1323351C (en) 2007-06-27

Family

ID=34284174

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB031152023A Expired - Fee Related CN1323351C (en) 2003-01-23 2003-01-23 Method for implementing a flow state machine

Country Status (1)

Country Link
CN (1) CN1323351C (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101964922A (en) * 2009-07-23 2011-02-02 中兴通讯股份有限公司 Abnormal condition capturing method and device
CN101247401B (en) * 2008-03-14 2011-05-25 中兴通讯股份有限公司 State machine processing method and device based on message driving
CN101652755B (en) * 2007-03-28 2013-03-27 株式会社Ntt都科摩 Software behavior modeling device, software behavior modeling method, software behavior verification device, and software behavior verification method
CN104239013A (en) * 2013-06-17 2014-12-24 上海联影医疗科技有限公司 Delegation based distributed state machine and processing method thereof
CN106548261A (en) * 2015-09-21 2017-03-29 阿里巴巴集团控股有限公司 A kind of Business Process Control method, device and electronic equipment
CN107977230A (en) * 2017-12-01 2018-05-01 广东雅达电子股份有限公司 A kind of application management method based on state machine mechanism

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5418968A (en) * 1990-10-31 1995-05-23 Gobeli; Gregg P. System and method for controlling interrupt processing
US6167047A (en) * 1998-05-18 2000-12-26 Solidum Systems Corp. Packet classification state machine

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101652755B (en) * 2007-03-28 2013-03-27 株式会社Ntt都科摩 Software behavior modeling device, software behavior modeling method, software behavior verification device, and software behavior verification method
CN101247401B (en) * 2008-03-14 2011-05-25 中兴通讯股份有限公司 State machine processing method and device based on message driving
CN101964922A (en) * 2009-07-23 2011-02-02 中兴通讯股份有限公司 Abnormal condition capturing method and device
CN101964922B (en) * 2009-07-23 2015-05-06 中兴通讯股份有限公司 Abnormal condition capturing method and device
CN104239013A (en) * 2013-06-17 2014-12-24 上海联影医疗科技有限公司 Delegation based distributed state machine and processing method thereof
CN104239013B (en) * 2013-06-17 2018-11-30 上海联影医疗科技有限公司 Distributing state machine and its processing method based on commission
CN106548261A (en) * 2015-09-21 2017-03-29 阿里巴巴集团控股有限公司 A kind of Business Process Control method, device and electronic equipment
CN107977230A (en) * 2017-12-01 2018-05-01 广东雅达电子股份有限公司 A kind of application management method based on state machine mechanism

Also Published As

Publication number Publication date
CN1323351C (en) 2007-06-27

Similar Documents

Publication Publication Date Title
CN1230737C (en) Device data polling dispatching method
CN100342342C (en) Java virtual machine implementation method supporting multi-process
CN101452404B (en) Task scheduling apparatus and method for embedded operating system
CN101135981A (en) Method and device for realizing batch report generation
CN109445944A (en) A kind of network data acquisition processing system and its method based on DPDK
CN1870767A (en) Method for managing timer task
CN102567111A (en) Method, system and terminal device capable of calling asynchronous procedure
CN101035047A (en) Processing method for loop network protection
CN1519706A (en) Method for implementing a flow state machine
CN100593146C (en) Method for preventing industrial automation system from snowslip
CN101056230A (en) Multi-center radio dynamic distributed network information collision prevention communication method
CN1277196C (en) Method for applied server of computer system
CN1423456A (en) Sharing route realizing and sheduling method
CN1225105C (en) Call processing system adapted for application server and its realizing method
CN1714342A (en) Concurrent operation of a state machine family
CN1955990B (en) Flow executing method and system of integral telecommunication platform
CN101281473B (en) Method and device for allocating pipe foot
CN101014176A (en) Collection scheduling method based on priority time linked list in communication network management system
CN1209207A (en) Job scheduling for intruction processor
CN1545302A (en) A method and system for distributed management of relay resources
CN101136766B (en) Task scheduling method for telecommunication network management system
CN1126036C (en) Platform of computer system
CN101707653A (en) Intelligent mobile terminal of single processor and realizing method thereof
CN113032131B (en) Redis-based distributed timing scheduling system and method
CN1145312C (en) network processor thread scheduling method

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20070627

Termination date: 20150123

EXPY Termination of patent right or utility model